diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-02-05 15:15:40 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-02-05 15:15:40 +0100 |
commit | 2355f4eb0b8fb33ef2d0994f4f54aa2615b8fa29 (patch) | |
tree | 857c280a7c3496409962652ab804c5f45f1f4da6 | |
parent | 4fb4bed8f103b4e26de97bd68a22d6b350d531f6 (diff) | |
download | askama-2355f4eb0b8fb33ef2d0994f4f54aa2615b8fa29.tar.gz askama-2355f4eb0b8fb33ef2d0994f4f54aa2615b8fa29.tar.bz2 askama-2355f4eb0b8fb33ef2d0994f4f54aa2615b8fa29.zip |
Simplify writing of template struct impl
-rw-r--r-- | askama/src/generator.rs | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/askama/src/generator.rs b/askama/src/generator.rs index 3650ddb..61d4fab 100644 --- a/askama/src/generator.rs +++ b/askama/src/generator.rs @@ -204,22 +204,17 @@ impl Generator { } fn template_impl(&mut self, ast: &syn::DeriveInput, nodes: &Vec<Node>) { - self.write("impl"); let anno = annotations(&ast.generics); - self.write(&anno); - self.write(" askama::Template for "); - self.write(ast.ident.as_ref()); - self.write(&anno); - self.writeln(" {"); - + self.writeln(&format!("impl{} askama::Template for {}{} {{", + anno, ast.ident.as_ref(), anno)); self.indent(); + self.writeln("fn render_into(&self, writer: &mut std::fmt::Write) {"); self.indent(); - self.handle(nodes); - self.dedent(); self.writeln("}"); + self.dedent(); self.writeln("}"); } |