From: Armin Ronacher Date: Thu, 15 May 2008 10:22:28 +0000 (+0200) Subject: reversed the internal structure for blocks X-Git-Tag: 2.0rc1~60 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=83fbc0fa7e5230d112683e63841550c637bd707c;p=jinja2.git reversed the internal structure for blocks --HG-- branch : trunk --- diff --git a/jinja2/compiler.py b/jinja2/compiler.py index cbac003..773203a 100644 --- a/jinja2/compiler.py +++ b/jinja2/compiler.py @@ -737,7 +737,7 @@ class CodeGenerator(NodeVisitor): self.writeline('if parent_template is None:') self.indent() level += 1 - self.writeline('for event in context.blocks[%r][-1](context):' % + self.writeline('for event in context.blocks[%r][0](context):' % node.name, node) self.indent() if frame.buffer is None: @@ -781,7 +781,7 @@ class CodeGenerator(NodeVisitor): 'blocks.iteritems():') self.indent() self.writeline('context.blocks.setdefault(name, []).' - 'insert(0, parent_block)') + 'append(parent_block)') self.outdent() # if this extends statement was in the root level we can take diff --git a/jinja2/runtime.py b/jinja2/runtime.py index 2605717..cbe7115 100644 --- a/jinja2/runtime.py +++ b/jinja2/runtime.py @@ -81,15 +81,13 @@ class Context(object): """Render a parent block.""" try: blocks = self.blocks[name] - pos = blocks.index(current) - 1 - if pos < 0: - raise IndexError() + block = blocks[blocks.index(current) + 1] except LookupError: return self.environment.undefined('there is no parent block ' 'called %r.' % name, name='super') wrap = self.environment.autoescape and Markup or (lambda x: x) - render = lambda: wrap(concat(blocks[pos](self))) + render = lambda: wrap(concat(block(self))) render.__name__ = render.name = name return render