diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2020-07-23 22:04:29 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2020-08-25 22:14:35 +0200 |
commit | ecafb9b10aa878f2598fd3a4a1deab62ffec40b8 (patch) | |
tree | 4c264f1efe6b9ae69a4a18323e54b0c8aaab3f5c /book/src/template_syntax.md | |
parent | b801724738563cd4481c5ca2b74458a37b499d21 (diff) | |
download | askama-ecafb9b10aa878f2598fd3a4a1deab62ffec40b8.tar.gz askama-ecafb9b10aa878f2598fd3a4a1deab62ffec40b8.tar.bz2 askama-ecafb9b10aa878f2598fd3a4a1deab62ffec40b8.zip |
Use efficient method for nested template rendering
Diffstat (limited to '')
-rw-r--r-- | book/src/template_syntax.md | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/book/src/template_syntax.md b/book/src/template_syntax.md index 6b98d99..6419140 100644 --- a/book/src/template_syntax.md +++ b/book/src/template_syntax.md @@ -304,7 +304,7 @@ testing and reuse. ```rust use askama::Template; #[derive(Template)] -#[template(source = "Section 1: {{ s1.render().unwrap() }}", ext = "txt")] +#[template(source = "Section 1: {{ s1 }}", ext = "txt")] struct RenderInPlace<'a> { s1: SectionOne<'a> } @@ -315,6 +315,7 @@ struct SectionOne<'a> { a: &'a str, b: &'a str, } + let t = RenderInPlace { s1: SectionOne { a: "a", b: "b" } }; assert_eq!(t.render().unwrap(), "Section 1: A=a\nB=b") ``` @@ -344,7 +345,7 @@ use askama::Template; #[derive(Template)] #[template(source = r#" //! {% for item in children %} - {{ item.render().unwrap() }} + {{ item }} {% endfor %} "#, ext = "html", escape = "none")] struct Item<'a> { |