Skip to content
Myr

reversed the internal structure for blocks

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent b3a1fcf · Browse files · 2 files+4 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+4 added−6 removed

  • other:+4 added−6 removed

2 files+4 added−6 removed

modified:jinja2/compiler.py+2 added-2 removed
735 unmodified lines
736 if self.extends_so_far > 0:737 self.writeline('if parent_template is None:')738 self.indent()739 level += 1740 self.writeline('for event in context.blocks[%r][-1](context):' %740 self.writeline('for event in context.blocks[%r][0](context):' %741 node.name, node)742 self.indent()743 if frame.buffer is None:744 self.writeline('yield event')
35 unmodified lines
780 self.writeline('for name, parent_block in parent_template.'781 'blocks.iteritems():')782 self.indent()783 self.writeline('context.blocks.setdefault(name, []).'784 'insert(0, parent_block)')784 'append(parent_block)')785 self.outdent()786787 # if this extends statement was in the root level we can take788 # advantage of that information and simplify the generated code
635 unmodified lines
modified:jinja2/runtime.py+2 added-4 removed
79 unmodified lines
80 def super(self, name, current):81 """Render a parent block."""82 try:83 blocks = self.blocks[name]84 pos = blocks.index(current) - 185 if pos < 0:86 raise IndexError()84 block = blocks[blocks.index(current) + 1]85 except LookupError:86 return self.environment.undefined('there is no parent block '87 'called %r.' % name,88 name='super')89 wrap = self.environment.autoescape and Markup or (lambda x: x)92 render = lambda: wrap(concat(blocks[pos](self)))90 render = lambda: wrap(concat(block(self)))91 render.__name__ = render.name = name92 return render9394 def get(self, key, default=None):
328 unmodified lines