aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-07-03 09:30:28 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-07-31 10:27:15 +0200
commit65fb5630825b62ca959fcb55252d1657aefea0f3 (patch)
tree8bad6fbd1db269e33ea1f40645a597bb4b37fc03 /askama_derive/src
parentf16ddb14f09e470f902ea5cb93e749685dd89d6a (diff)
downloadaskama-65fb5630825b62ca959fcb55252d1657aefea0f3.tar.gz
askama-65fb5630825b62ca959fcb55252d1657aefea0f3.tar.bz2
askama-65fb5630825b62ca959fcb55252d1657aefea0f3.zip
parser: define a struct for Match
Diffstat (limited to '')
-rw-r--r--askama_derive/src/generator.rs7
-rw-r--r--askama_derive/src/heritage.rs4
2 files changed, 5 insertions, 6 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs
index addde7a..66f1b1c 100644
--- a/askama_derive/src/generator.rs
+++ b/askama_derive/src/generator.rs
@@ -796,8 +796,7 @@ impl<'a> Generator<'a> {
let mut arm_size = 0;
for (i, arm) in arms.iter().enumerate() {
- let &(ws, ref target, ref body) = arm;
- self.handle_ws(ws);
+ self.handle_ws(arm.ws);
if i > 0 {
arm_sizes.push(arm_size + self.write_buf_writable(buf)?);
@@ -807,10 +806,10 @@ impl<'a> Generator<'a> {
}
self.locals.push();
- self.visit_target(buf, true, true, target);
+ self.visit_target(buf, true, true, &arm.target);
buf.writeln(" => {")?;
- arm_size = self.handle(ctx, body, buf, AstLevel::Nested)?;
+ arm_size = self.handle(ctx, &arm.block, buf, AstLevel::Nested)?;
}
self.handle_ws(ws2);
diff --git a/askama_derive/src/heritage.rs b/askama_derive/src/heritage.rs
index 66f1a1a..342416e 100644
--- a/askama_derive/src/heritage.rs
+++ b/askama_derive/src/heritage.rs
@@ -94,8 +94,8 @@ impl Context<'_> {
nested.push(else_block);
}
Node::Match(_, _, arms, _) => {
- for (_, _, arm) in arms {
- nested.push(arm);
+ for arm in arms {
+ nested.push(&arm.block);
}
}
_ => {}