Comments (3)
Theoretically in this case the safe
should not be necessary since the inner value is itself a template which means it is inherently safe. Unfortunately this is blocked by a lack of support for specialization.
from askama.
Askama implicitly escapes text, when you do {{ form }}
. If you want to suppress that, then use {{ form|safe }}
.
However, it sounds like there's more to the question than just that. If so, can you maybe provide some dummy code, to illustrate what you're trying to do?
To give a more complete example. What it sounds like to me, is that you're trying to do something like this:
use askama::Template;
#[derive(Template)]
#[template(source = "<form>Some Form</form>", ext = "html")]
pub struct Form {}
#[derive(Template)]
#[template(source = "Form:\n<br>\n{{ form|safe }}", ext = "html")]
struct Page {
form: Form,
}
let page = Page { form: Form {} };
println!("{}", page.render().unwrap());
Note the |safe
in Page
's source. That suppresses escaping the HTML entities. So page.render()
results in:
Form:
<br>
<form>Some Form</form>
from askama.
That's exactly what I wanted and works perfectly. Thank you very much!
from askama.
Related Issues (20)
- Float literals are not completely supported HOT 1
- Add support for single quote strings? HOT 7
- Allow output of not prettified JSON data
- Compilation error when using nested template blocks with in a single template file HOT 3
- HELP: about askama_axum::Template HOT 2
- Nested comments causes parser to timeout HOT 2
- Publish all crate versions books HOT 7
- if let chain has a weird behaviour HOT 2
- `include` is not very efficient HOT 3
- 0.13.0 release planning HOT 2
- Add tests for generated code HOT 2
- When using askama_axum, the automatic import of IntoResponse will preferentially import from askama_axum instead of axum::response. HOT 4
- Deny all / more reserved keywords as macro names
- Using block fragments as part of larger template HOT 2
- Unnecessary fields required when using blocks for partial rendering HOT 3
- Add `elif` keyword HOT 2
- Template Rendering of a Result<T + Display, E + Display> Cleanly HOT 3
- Feature/docs request: allow setting escape="none" in askama.toml HOT 2
- Include statement has no effect when used from a block fragment HOT 7
- Feedback for me HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from askama.