diff options
author | max <gmx.sht@gmail.com> | 2023-12-11 16:39:03 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2024-01-17 17:58:53 +0100 |
commit | 514ae1b24cebb50cad04d0717092a9f890b7a245 (patch) | |
tree | d24859ec1fb4f889e4b20ea708b023669af56d50 /askama_derive/src | |
parent | b1386c1fbf05b9a5f2973c3755c52246b9debe6c (diff) | |
download | askama-514ae1b24cebb50cad04d0717092a9f890b7a245.tar.gz askama-514ae1b24cebb50cad04d0717092a9f890b7a245.tar.bz2 askama-514ae1b24cebb50cad04d0717092a9f890b7a245.zip |
Refactored `match node` in `find_used_templates`
Signed-off-by: max <gmx.sht@gmail.com>
Diffstat (limited to '')
-rw-r--r-- | askama_derive/src/input.rs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/askama_derive/src/input.rs b/askama_derive/src/input.rs index d10fd7f..57fbc04 100644 --- a/askama_derive/src/input.rs +++ b/askama_derive/src/input.rs @@ -114,8 +114,9 @@ impl TemplateInput<'_> { while let Some((path, source)) = check.pop() { let parsed = Parsed::new(source, self.syntax)?; for n in parsed.nodes() { + use Node::*; match n { - Node::Extends(extends) => { + Extends(extends) => { let extends = self.config.find_template(extends.path, Some(&path))?; let dependency_path = (path.clone(), extends.clone()); if dependency_graph.contains(&dependency_path) { @@ -132,12 +133,25 @@ impl TemplateInput<'_> { let source = get_template_source(&extends)?; check.push((extends, source)); } - Node::Import(import) => { + Import(import) => { let import = self.config.find_template(import.path, Some(&path))?; let source = get_template_source(&import)?; check.push((import, source)); } - _ => {} + If(_) + | Loop(_) + | Match(_) + | BlockDef(_) + | Include(_) + | Lit(_) + | Comment(_) + | Expr(_, _) + | Call(_) + | Let(_) + | Macro(_) + | Raw(_) + | Continue(_) + | Break(_) => {} } } map.insert(path, parsed); |