aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-07-03 09:27:04 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-07-31 10:27:15 +0200
commitf16ddb14f09e470f902ea5cb93e749685dd89d6a (patch)
treed12d2de512549b5f1917e9a823c467136a41cb4f /askama_derive
parentcdbe8ef39f74fa978f4f2e8ac25acfee2c4432aa (diff)
downloadaskama-f16ddb14f09e470f902ea5cb93e749685dd89d6a.tar.gz
askama-f16ddb14f09e470f902ea5cb93e749685dd89d6a.tar.bz2
askama-f16ddb14f09e470f902ea5cb93e749685dd89d6a.zip
parser: define a struct for Cond
Diffstat (limited to 'askama_derive')
-rw-r--r--askama_derive/src/generator.rs8
-rw-r--r--askama_derive/src/heritage.rs4
2 files changed, 6 insertions, 6 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs
index 0c482b5..addde7a 100644
--- a/askama_derive/src/generator.rs
+++ b/askama_derive/src/generator.rs
@@ -718,8 +718,8 @@ impl<'a> Generator<'a> {
let mut flushed = 0;
let mut arm_sizes = Vec::new();
let mut has_else = false;
- for (i, &(cws, ref cond, ref nodes)) in conds.iter().enumerate() {
- self.handle_ws(cws);
+ for (i, cond) in conds.iter().enumerate() {
+ self.handle_ws(cond.ws);
flushed += self.write_buf_writable(buf)?;
if i > 0 {
self.locals.pop();
@@ -727,7 +727,7 @@ impl<'a> Generator<'a> {
self.locals.push();
let mut arm_size = 0;
- if let Some(CondTest { target, expr }) = cond {
+ if let Some(CondTest { target, expr }) = &cond.cond {
if i == 0 {
buf.write("if ");
} else {
@@ -762,7 +762,7 @@ impl<'a> Generator<'a> {
buf.writeln(" {")?;
- arm_size += self.handle(ctx, nodes, buf, AstLevel::Nested)?;
+ arm_size += self.handle(ctx, &cond.block, buf, AstLevel::Nested)?;
arm_sizes.push(arm_size);
}
self.handle_ws(ws);
diff --git a/askama_derive/src/heritage.rs b/askama_derive/src/heritage.rs
index 38c2cc8..66f1a1a 100644
--- a/askama_derive/src/heritage.rs
+++ b/askama_derive/src/heritage.rs
@@ -83,8 +83,8 @@ impl Context<'_> {
}
}
Node::Cond(branches, _) => {
- for (_, _, nodes) in branches {
- nested.push(nodes);
+ for cond in branches {
+ nested.push(&cond.block);
}
}
Node::Loop(Loop {