reversed the internal structure for blocks
authorArmin Ronacher <armin.ronacher@active-4.com>
Thu, 15 May 2008 10:22:28 +0000 (12:22 +0200)
committerArmin Ronacher <armin.ronacher@active-4.com>
Thu, 15 May 2008 10:22:28 +0000 (12:22 +0200)
--HG--
branch : trunk

jinja2/compiler.py
jinja2/runtime.py

index cbac00317d74141058efe164780ed91b3c492a67..773203a47802390f53cce822a82f0d51aa905dc0 100644 (file)
@@ -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
index 2605717c2dd889b1ddd15b0a235757782d281ee9..cbe7115bf9a48465caf3c014b388755b6ecebfa9 100644 (file)
@@ -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