diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-02-05 10:13:22 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-02-05 10:13:22 +0100 |
commit | 715eed3aeeb8e5d0cbb420239432cda69e6131f8 (patch) | |
tree | 758a36453cb474a1a9dac2ed912ce8237bc4f1e7 | |
parent | f98b6285ba11d2d1580ff8be37d0fd7b60107733 (diff) | |
download | askama-715eed3aeeb8e5d0cbb420239432cda69e6131f8.tar.gz askama-715eed3aeeb8e5d0cbb420239432cda69e6131f8.tar.bz2 askama-715eed3aeeb8e5d0cbb420239432cda69e6131f8.zip |
Improve name and ownership of AST vector
-rw-r--r-- | askama/src/generator.rs | 12 | ||||
-rw-r--r-- | askama_derive/src/lib.rs | 4 |
2 files changed, 8 insertions, 8 deletions
diff --git a/askama/src/generator.rs b/askama/src/generator.rs index f262f7c..4c91d14 100644 --- a/askama/src/generator.rs +++ b/askama/src/generator.rs @@ -147,8 +147,8 @@ impl Generator { } } - fn handle(&mut self, tokens: &Vec<Node>) { - for n in tokens { + fn handle(&mut self, nodes: &Vec<Node>) { + for n in nodes { match n { &Node::Lit(val) => { self.write_lit(val); }, &Node::Expr(ref val) => { self.write_expr(&val); }, @@ -173,7 +173,7 @@ impl Generator { res } - fn template_impl(&mut self, ast: &syn::DeriveInput, tokens: &Vec<Node>) { + fn template_impl(&mut self, ast: &syn::DeriveInput, nodes: &Vec<Node>) { self.write("impl"); let anno = self.annotations(&ast.generics); self.write(&anno); @@ -186,7 +186,7 @@ impl Generator { self.writeln("fn render_into(&self, writer: &mut std::fmt::Write) {"); self.indent(); - self.handle(tokens); + self.handle(nodes); self.dedent(); self.writeln("}"); @@ -200,8 +200,8 @@ impl Generator { } -pub fn generate(ast: &syn::DeriveInput, tokens: &Vec<Node>) -> String { +pub fn generate(ast: &syn::DeriveInput, nodes: Vec<Node>) -> String { let mut gen = Generator::new(); - gen.template_impl(ast, tokens); + gen.template_impl(ast, &nodes); gen.result() } diff --git a/askama_derive/src/lib.rs b/askama_derive/src/lib.rs index cdb0dd9..03bfe7d 100644 --- a/askama_derive/src/lib.rs +++ b/askama_derive/src/lib.rs @@ -58,6 +58,6 @@ pub fn derive_template(input: TokenStream) -> TokenStream { let path = get_path_from_attrs(&ast.attrs); let src = get_template_source(&path); - let tokens = askama::parser::parse(&src); - askama::generator::generate(&ast, &tokens).parse().unwrap() + let nodes = askama::parser::parse(&src); + askama::generator::generate(&ast, nodes).parse().unwrap() } |