diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index c2a8498d1..a7624dae6 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -865,13 +865,13 @@ impl<'a> Generator<'a> { None }; + let handle_ctx = match &heritage { + Some(heritage) => heritage.root, + None => child_ctx, + }; let locals = MapChain::with_parent(&self.locals); let mut child = Self::new(self.input, self.contexts, heritage.as_ref(), locals); - let mut size_hint = if let Some(heritage) = &heritage { - child.handle(heritage.root, heritage.root.nodes, buf, AstLevel::Top) - } else { - child.handle(child_ctx, child_ctx.nodes, buf, AstLevel::Top) - }?; + let mut size_hint = child.handle(handle_ctx, handle_ctx.nodes, buf, AstLevel::Top)?; size_hint += child.write_buf_writable(buf)?; self.prepare_ws(i.ws);