diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-06-22 20:35:49 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-06-22 20:35:49 +0200 |
commit | c6fe641b33c5021aadcb8a97927bf7810d610aef (patch) | |
tree | 0944b77f05be4fe7ccd43fdccb53ca4f269db909 /askama_derive | |
parent | fc78b97cbc88ffd53149415e2f6201103949e04b (diff) | |
download | askama-c6fe641b33c5021aadcb8a97927bf7810d610aef.tar.gz askama-c6fe641b33c5021aadcb8a97927bf7810d610aef.tar.bz2 askama-c6fe641b33c5021aadcb8a97927bf7810d610aef.zip |
Reorder some code
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); |