Skip to content

Commit

Permalink
Suggest disable html escaping in templates in templates section (#1089)
Browse files Browse the repository at this point in the history
  • Loading branch information
malteneuss authored Aug 26, 2024
1 parent 10a4264 commit a6f95cd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions book/src/template_syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,11 @@ let t = RenderInPlace { s1: SectionOne { a: "a", b: "b" } };
assert_eq!(t.render().unwrap(), "Section 1: A=a\nB=b")
```

**Note that if your inner template** like `SectionOne` **renders HTML content, you may want to
disable escaping** when injecting it into an outer template, e.g. `{{ s1|safe }}`.
Otherwise it will render the HTML content literally, because
Askama [escapes HTML variables](#html-escaping) by default.

See the example
[render in place](https://github.com/djc/askama/blob/main/testing/tests/render_in_place.rs)
using a vector of templates in a for block.
Expand Down

0 comments on commit a6f95cd

Please sign in to comment.