aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--askama_derive/src/generator.rs6
-rw-r--r--askama_derive/src/heritage.rs8
-rw-r--r--askama_parser/src/node.rs25
3 files changed, 21 insertions, 18 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs
index 66f1b1c..5308c02 100644
--- a/askama_derive/src/generator.rs
+++ b/askama_derive/src/generator.rs
@@ -762,7 +762,7 @@ impl<'a> Generator<'a> {
buf.writeln(" {")?;
- arm_size += self.handle(ctx, &cond.block, buf, AstLevel::Nested)?;
+ arm_size += self.handle(ctx, &cond.nodes, buf, AstLevel::Nested)?;
arm_sizes.push(arm_size);
}
self.handle_ws(ws);
@@ -809,7 +809,7 @@ impl<'a> Generator<'a> {
self.visit_target(buf, true, true, &arm.target);
buf.writeln(" => {")?;
- arm_size = self.handle(ctx, &arm.block, buf, AstLevel::Nested)?;
+ arm_size = self.handle(ctx, &arm.nodes, buf, AstLevel::Nested)?;
}
self.handle_ws(ws2);
@@ -881,7 +881,7 @@ impl<'a> Generator<'a> {
buf.writeln("if !_did_loop {")?;
self.locals.push();
- let mut size_hint2 = self.handle(ctx, &loop_block.else_block, buf, AstLevel::Nested)?;
+ let mut size_hint2 = self.handle(ctx, &loop_block.else_nodes, buf, AstLevel::Nested)?;
self.handle_ws(loop_block.ws3);
size_hint2 += self.write_buf_writable(buf)?;
self.locals.pop();
diff --git a/askama_derive/src/heritage.rs b/askama_derive/src/heritage.rs
index 342416e..9ef7aeb 100644
--- a/askama_derive/src/heritage.rs
+++ b/askama_derive/src/heritage.rs
@@ -84,18 +84,20 @@ impl Context<'_> {
}
Node::Cond(branches, _) => {
for cond in branches {
- nested.push(&cond.block);
+ nested.push(&cond.nodes);
}
}
Node::Loop(Loop {
- body, else_block, ..
+ body,
+ else_nodes: else_block,
+ ..
}) => {
nested.push(body);
nested.push(else_block);
}
Node::Match(_, _, arms, _) => {
for arm in arms {
- nested.push(&arm.block);
+ nested.push(&arm.nodes);
}
}
_ => {}
diff --git a/askama_parser/src/node.rs b/askama_parser/src/node.rs
index 2a19ee9..b9685e8 100644
--- a/askama_parser/src/node.rs
+++ b/askama_parser/src/node.rs
@@ -147,14 +147,15 @@ impl<'a> Node<'a> {
))),
))),
));
- let (i, (pws1, cond, (nws1, _, (block, elifs, (_, pws2, _, nws2))))) = p(i)?;
+ let (i, (pws1, cond, (nws1, _, (nodes, elifs, (_, pws2, _, nws2))))) = p(i)?;
let mut res = vec![Cond {
ws: Ws(pws1, nws1),
cond: Some(cond),
- block,
+ nodes,
}];
res.extend(elifs);
+
Ok((i, Self::Cond(res, Ws(pws2, nws2))))
}
@@ -219,7 +220,7 @@ impl<'a> Node<'a> {
cond,
body,
ws2: Ws(pws2, nws3),
- else_block,
+ else_nodes: else_block,
ws3: Ws(pws3, nws2),
}),
))
@@ -582,7 +583,7 @@ impl<'a> Target<'a> {
pub struct When<'a> {
pub ws: Ws,
pub target: Target<'a>,
- pub block: Vec<Node<'a>>,
+ pub nodes: Vec<Node<'a>>,
}
impl<'a> When<'a> {
@@ -597,13 +598,13 @@ impl<'a> When<'a> {
cut(|i| Node::many(i, s)),
))),
));
- let (i, (_, pws, _, (nws, _, block))) = p(i)?;
+ let (i, (_, pws, _, (nws, _, nodes))) = p(i)?;
Ok((
i,
Self {
ws: Ws(pws, nws),
target: Target::Name("_"),
- block,
+ nodes,
},
))
}
@@ -621,13 +622,13 @@ impl<'a> When<'a> {
cut(|i| Node::many(i, s)),
))),
));
- let (i, (_, pws, _, (target, nws, _, block))) = p(i)?;
+ let (i, (_, pws, _, (target, nws, _, nodes))) = p(i)?;
Ok((
i,
Self {
ws: Ws(pws, nws),
target,
- block,
+ nodes,
},
))
}
@@ -637,7 +638,7 @@ impl<'a> When<'a> {
pub struct Cond<'a> {
pub ws: Ws,
pub cond: Option<CondTest<'a>>,
- pub block: Vec<Node<'a>>,
+ pub nodes: Vec<Node<'a>>,
}
impl<'a> Cond<'a> {
@@ -653,13 +654,13 @@ impl<'a> Cond<'a> {
cut(|i| Node::many(i, s)),
))),
));
- let (i, (_, pws, _, (cond, nws, _, block))) = p(i)?;
+ let (i, (_, pws, _, (cond, nws, _, nodes))) = p(i)?;
Ok((
i,
Self {
ws: Ws(pws, nws),
cond,
- block,
+ nodes,
},
))
}
@@ -721,7 +722,7 @@ pub struct Loop<'a> {
pub cond: Option<Expr<'a>>,
pub body: Vec<Node<'a>>,
pub ws2: Ws,
- pub else_block: Vec<Node<'a>>,
+ pub else_nodes: Vec<Node<'a>>,
pub ws3: Ws,
}