aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src/generator.rs
diff options
context:
space:
mode:
Diffstat (limited to 'askama_derive/src/generator.rs')
-rw-r--r--askama_derive/src/generator.rs20
1 files changed, 6 insertions, 14 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs
index 60ffa27..beb3c49 100644
--- a/askama_derive/src/generator.rs
+++ b/askama_derive/src/generator.rs
@@ -650,8 +650,8 @@ impl<'a> Generator<'a> {
Node::Loop(ref loop_block) => {
size_hint += self.write_loop(ctx, buf, loop_block)?;
}
- Node::BlockDef(ws1, name, _, ws2) => {
- size_hint += self.write_block(buf, Some(name), Ws(ws1.0, ws2.1))?;
+ Node::BlockDef(ref b) => {
+ size_hint += self.write_block(buf, Some(b.name), Ws(b.ws1.0, b.ws2.1))?;
}
Node::Include(ws, path) => {
size_hint += self.handle_include(ctx, buf, ws, path)?;
@@ -1163,26 +1163,18 @@ impl<'a> Generator<'a> {
// Get the block definition from the heritage chain
let heritage = self
.heritage
- .as_ref()
.ok_or_else(|| CompileError::from("no block ancestors available"))?;
- let (ctx, def) = heritage.blocks[cur.0].get(cur.1).ok_or_else(|| {
+ let (ctx, def) = *heritage.blocks[cur.0].get(cur.1).ok_or_else(|| {
CompileError::from(match name {
None => format!("no super() block found for block '{}'", cur.0),
Some(name) => format!("no block found for name '{name}'"),
})
})?;
- // Get the nodes and whitespace suppression data from the block definition
- let (ws1, nodes, ws2) = if let Node::BlockDef(ws1, _, nodes, ws2) = def {
- (ws1, nodes, ws2)
- } else {
- unreachable!()
- };
-
// Handle inner whitespace suppression spec and process block nodes
- self.prepare_ws(*ws1);
+ self.prepare_ws(def.ws1);
self.locals.push();
- let size_hint = self.handle(ctx, nodes, buf, AstLevel::Block)?;
+ let size_hint = self.handle(ctx, &def.nodes, buf, AstLevel::Block)?;
if !self.locals.is_current_empty() {
// Need to flush the buffer before popping the variable stack
@@ -1190,7 +1182,7 @@ impl<'a> Generator<'a> {
}
self.locals.pop();
- self.flush_ws(*ws2);
+ self.flush_ws(def.ws2);
// Restore original block context and set whitespace suppression for
// succeeding whitespace according to the outer WS spec