From dfb7cea03794ead892527e19f883dc8a3e784bc7 Mon Sep 17 00:00:00 2001 From: bott Date: Sun, 2 Sep 2018 18:46:45 +0200 Subject: Fix multiple nesting in macro calls into different scopes --- askama_derive/src/generator.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'askama_derive/src') diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index b771234..81c0e27 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -427,13 +427,15 @@ impl<'a> Generator<'a> { return; } - let def = if let Some(s) = match scope { + let own_scope = match scope { None => match level { AstLevel::Nested(s) => s, _ => None, }, s => s, - } { + }; + + let def = if let Some(s) = own_scope { let path = ctx .imports .get(s) @@ -464,7 +466,7 @@ impl<'a> Generator<'a> { buf.writeln(&format!("let {} = &{};", arg, expr_code)); self.locals.insert(arg); } - self.handle(ctx, &def.nodes, buf, AstLevel::Nested(scope)); + self.handle(ctx, &def.nodes, buf, AstLevel::Nested(own_scope)); self.flush_ws(buf, def.ws2); buf.writeln("}"); -- cgit