From 83fbc0fa7e5230d112683e63841550c637bd707c Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Thu, 15 May 2008 12:22:28 +0200 Subject: [PATCH] reversed the internal structure for blocks --HG-- branch : trunk --- jinja2/compiler.py | 4 ++-- jinja2/runtime.py | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) 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 -- 2.26.2