From 222c42917aa19162562b8a9c35350e3e992f9823 Mon Sep 17 00:00:00 2001 From: René Kijewski Date: Tue, 1 Aug 2023 03:09:35 +0200 Subject: parser: let `Macro` know its name --- askama_derive/src/generator.rs | 2 +- askama_derive/src/heritage.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'askama_derive') diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 5308c02..1c6e722 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -659,7 +659,7 @@ impl<'a> Generator<'a> { Node::Call(ws, scope, name, ref args) => { size_hint += self.write_call(ctx, buf, ws, scope, name, args)?; } - Node::Macro(_, ref m) => { + Node::Macro(ref m) => { if level != AstLevel::Top { return Err("macro blocks only allowed at the top level".into()); } diff --git a/askama_derive/src/heritage.rs b/askama_derive/src/heritage.rs index 9ef7aeb..801b109 100644 --- a/askama_derive/src/heritage.rs +++ b/askama_derive/src/heritage.rs @@ -64,14 +64,14 @@ impl Context<'_> { extends = Some(config.find_template(extends_path, Some(path))?); } }, - Node::Macro(name, m) if top => { - macros.insert(*name, m); + Node::Macro(m) if top => { + macros.insert(m.name, m); } Node::Import(_, import_path, scope) if top => { let path = config.find_template(import_path, Some(path))?; imports.insert(*scope, path); } - Node::Extends(_) | Node::Macro(_, _) | Node::Import(_, _, _) if !top => { + Node::Extends(_) | Node::Macro(_) | Node::Import(_, _, _) if !top => { return Err( "extends, macro or import blocks not allowed below top level".into(), ); -- cgit