aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-09-26 17:06:48 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-09-26 17:06:48 +0200
commit1d914727b137b684edd0d64e6d0b30ab155fa87c (patch)
treee09943001bfe76dc8ae3faf6c674a1fc97eb3f45
parentdf58dcb49db77b2c283db3c9a8a738bdff3a8e37 (diff)
downloadaskama-1d914727b137b684edd0d64e6d0b30ab155fa87c.tar.gz
askama-1d914727b137b684edd0d64e6d0b30ab155fa87c.tar.bz2
askama-1d914727b137b684edd0d64e6d0b30ab155fa87c.zip
Insert macro parameter into locals after defining it (fixes #53)
-rw-r--r--askama_shared/src/generator.rs2
1 files changed, 1 insertions, 1 deletions
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);