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:
'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
"""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