diff options
author | René Kijewski <rene.kijewski@fu-berlin.de> | 2023-08-01 03:18:10 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2023-08-01 13:04:41 +0200 |
commit | cd075630eab578a66afec6000ce0f266e6b281e8 (patch) | |
tree | 8effbf0c2ab4ff2fb6697ec774180bff6c5c5141 /askama_derive | |
parent | 222c42917aa19162562b8a9c35350e3e992f9823 (diff) | |
download | askama-cd075630eab578a66afec6000ce0f266e6b281e8.tar.gz askama-cd075630eab578a66afec6000ce0f266e6b281e8.tar.bz2 askama-cd075630eab578a66afec6000ce0f266e6b281e8.zip |
parser: add type for `Node::Import`
Diffstat (limited to '')
-rw-r--r-- | askama_derive/src/generator.rs | 8 | ||||
-rw-r--r-- | askama_derive/src/heritage.rs | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 1c6e722..8a2c0e3 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -228,8 +228,8 @@ fn find_used_templates( let source = get_template_source(&extends)?; check.push((extends, source)); } - Node::Import(_, import, _) => { - let import = input.config.find_template(import, Some(&path))?; + Node::Import(import) => { + let import = input.config.find_template(import.path, Some(&path))?; let source = get_template_source(&import)?; check.push((import, source)); } @@ -671,11 +671,11 @@ impl<'a> Generator<'a> { self.visit_lit(lws, val, rws); self.handle_ws(ws2); } - Node::Import(ws, _, _) => { + Node::Import(ref i) => { if level != AstLevel::Top { return Err("import blocks only allowed at the top level".into()); } - self.handle_ws(ws); + self.handle_ws(i.ws); } Node::Extends(_) => { if level != AstLevel::Top { diff --git a/askama_derive/src/heritage.rs b/askama_derive/src/heritage.rs index 801b109..9f642e3 100644 --- a/askama_derive/src/heritage.rs +++ b/askama_derive/src/heritage.rs @@ -67,11 +67,11 @@ impl Context<'_> { 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::Import(import) if top => { + let path = config.find_template(import.path, Some(path))?; + imports.insert(import.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(), ); |