diff options
Diffstat (limited to '')
-rw-r--r-- | askama_derive/src/generator.rs | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 86ccfd3..59d8134 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -97,6 +97,26 @@ impl<'a> Generator<'a> { self.buf } + // Implement `Template` for the given context struct. + fn impl_template(&mut self, ctx: &'a Context, heritage: &Option<Heritage<'a>>) { + self.write_header("::askama::Template", None); + self.writeln( + "fn render_into(&self, writer: &mut ::std::fmt::Write) -> \ + ::askama::Result<()> {", + ); + + if let Some(heritage) = heritage { + self.handle(heritage.root, heritage.root.nodes, AstLevel::Top); + } else { + self.handle(ctx, &ctx.nodes, AstLevel::Top); + } + + self.flush_ws(WS(false, false)); + self.writeln("Ok(())"); + self.writeln("}"); + self.writeln("}"); + } + fn trait_blocks(&mut self, heritage: &Heritage<'a>) { let trait_name = format!("{}Blocks", self.input.ast.ident); let mut methods = vec![]; @@ -152,26 +172,6 @@ impl<'a> Generator<'a> { self.writeln("}"); } - // Implement `Template` for the given context struct. - fn impl_template(&mut self, ctx: &'a Context, heritage: &Option<Heritage<'a>>) { - self.write_header("::askama::Template", None); - self.writeln( - "fn render_into(&self, writer: &mut ::std::fmt::Write) -> \ - ::askama::Result<()> {", - ); - - if let Some(heritage) = heritage { - self.handle(heritage.root, heritage.root.nodes, AstLevel::Top); - } else { - self.handle(ctx, &ctx.nodes, AstLevel::Top); - } - - self.flush_ws(WS(false, false)); - self.writeln("Ok(())"); - self.writeln("}"); - self.writeln("}"); - } - // Implement `Deref<Parent>` for an inheriting context struct. fn deref_to_parent(&mut self, parent_type: &syn::Type) { self.write_header("::std::ops::Deref", None); |