From c6fe641b33c5021aadcb8a97927bf7810d610aef Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Fri, 22 Jun 2018 20:35:49 +0200 Subject: Reorder some code --- askama_derive/src/generator.rs | 40 ++++++++++++++++++++-------------------- 1 file 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>) { + 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>) { - 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` for an inheriting context struct. fn deref_to_parent(&mut self, parent_type: &syn::Type) { self.write_header("::std::ops::Deref", None); -- cgit