aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar René Kijewski <rene.kijewski@fu-berlin.de>2023-08-01 12:49:17 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-08-01 13:04:41 +0200
commitc8399c75ed0b90f0976ffeaa220150b8c1c22421 (patch)
tree4f19dd967f032c368602d7115a122401b5550870
parent11f3d0714ce20a45aa929052ce57e969f9048f72 (diff)
downloadaskama-c8399c75ed0b90f0976ffeaa220150b8c1c22421.tar.gz
askama-c8399c75ed0b90f0976ffeaa220150b8c1c22421.tar.bz2
askama-c8399c75ed0b90f0976ffeaa220150b8c1c22421.zip
parser: `node::Loop` is much bigger than the other variants
Diffstat (limited to '')
-rw-r--r--askama_derive/src/heritage.rs12
-rw-r--r--askama_parser/src/node.rs4
2 files changed, 6 insertions, 10 deletions
diff --git a/askama_derive/src/heritage.rs b/askama_derive/src/heritage.rs
index d34ef33..4e12f35 100644
--- a/askama_derive/src/heritage.rs
+++ b/askama_derive/src/heritage.rs
@@ -4,7 +4,7 @@ use std::path::{Path, PathBuf};
use crate::config::Config;
use crate::CompileError;
-use parser::node::{BlockDef, Loop, Macro, Match, Node};
+use parser::node::{BlockDef, Macro, Match, Node};
pub(crate) struct Heritage<'a> {
pub(crate) root: &'a Context<'a>,
@@ -86,13 +86,9 @@ impl Context<'_> {
nested.push(&cond.nodes);
}
}
- Node::Loop(Loop {
- body,
- else_nodes: else_block,
- ..
- }) => {
- nested.push(body);
- nested.push(else_block);
+ Node::Loop(l) => {
+ nested.push(&l.body);
+ nested.push(&l.else_nodes);
}
Node::Match(Match { arms, .. }) => {
for arm in arms {
diff --git a/askama_parser/src/node.rs b/askama_parser/src/node.rs
index 2d82868..02b90b5 100644
--- a/askama_parser/src/node.rs
+++ b/askama_parser/src/node.rs
@@ -23,7 +23,7 @@ pub enum Node<'a> {
Let(Let<'a>),
If(If<'a>),
Match(Match<'a>),
- Loop(Loop<'a>),
+ Loop(Box<Loop<'a>>),
Extends(Extends<'a>),
BlockDef(BlockDef<'a>),
Include(Include<'a>),
@@ -51,7 +51,7 @@ impl<'a> Node<'a> {
map(Call::parse, Self::Call),
map(Let::parse, Self::Let),
map(|i| If::parse(i, s), Self::If),
- map(|i| Loop::parse(i, s), Self::Loop),
+ map(|i| Loop::parse(i, s), |l| Self::Loop(Box::new(l))),
map(|i| Match::parse(i, s), Self::Match),
map(Extends::parse, Self::Extends),
map(Include::parse, Self::Include),