From 7a52df8ec3d2987076181171b3227ab56154ab10 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Fri, 11 Apr 2008 13:58:22 +0200 Subject: [PATCH] fixed a small bug --HG-- branch : trunk --- jinja2/compiler.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jinja2/compiler.py b/jinja2/compiler.py index 343449c..66af667 100644 --- a/jinja2/compiler.py +++ b/jinja2/compiler.py @@ -325,7 +325,7 @@ class CodeGenerator(NodeVisitor): self.writeline('for event in parent_root(context):') self.indent() self.writeline('yield event') - self.outdent(2 + self.has_known_extends) + self.outdent(1 + self.has_known_extends) # at this point we now have the blocks collected and can visit them too. for name, block in self.blocks.iteritems(): @@ -343,12 +343,12 @@ class CodeGenerator(NodeVisitor): """Call a block and register it for the template.""" # if we know that we are a child template, there is no need to # check if we are one - if self.has_known_extends: + if self.has_known_extends and frame.toplevel: return if frame.toplevel: self.writeline('if parent_root is None:') self.indent() - self.writeline('for event in block_%s(context):' % node.name) + self.writeline('for event in context.blocks[-1][%r](context):' % node.name) self.indent() self.writeline('yield event') self.outdent(1 + frame.toplevel) @@ -506,7 +506,7 @@ class CodeGenerator(NodeVisitor): def visit_Output(self, node, frame): # if we have a known extends statement, we don't output anything - if self.has_known_extends: + if self.has_known_extends and frame.toplevel: return self.newline(node) -- 2.26.2