From 1d914727b137b684edd0d64e6d0b30ab155fa87c Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Tue, 26 Sep 2017 17:06:48 +0200 Subject: Insert macro parameter into locals after defining it (fixes #53) --- askama_shared/src/generator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs index e135c13..a37b51f 100644 --- a/askama_shared/src/generator.rs +++ b/askama_shared/src/generator.rs @@ -442,10 +442,10 @@ impl<'a> Generator<'a> { self.prepare_ws(&def.ws1); for (i, arg) in def.args.iter().enumerate() { self.write(&format!("let {} = &", arg)); - self.locals.insert(arg); self.visit_expr(args.get(i) .expect(&format!("macro '{}' takes more than {} arguments", name, i))); self.writeln(";"); + self.locals.insert(arg); } self.handle(state, &def.nodes, AstLevel::Nested); self.flush_ws(&def.ws2); -- cgit