Skip to content
Myr

Added proper super() support for scoped 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 74a0cd9 · Browse files · 2 files+13 added−2 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+13 added−2 removed

  • tests:+9 added−0 removed
  • other:+4 added−2 removed

2 files+13 added−2 removed

modified:jinja2/runtime.py+4 added-2 removed
171 unmodified lines
172 return __obj(*args, **kwargs)173174 def derived(self, locals=None):175 """Internal helper function to create a derived context."""176 return new_context(self.environment, self.name, self.blocks,177 self.parent, True, None, locals)176 context = new_context(self.environment, self.name, {},177 self.parent, True, None, locals)178 context.blocks.update((k, list(v)) for k, v in self.blocks.iteritems())179 return context180181 def _all(meth):182 proxy = lambda self: getattr(self.get_all(), meth)()183 proxy.__doc__ = getattr(dict, meth).__doc__
329 unmodified lines
modified:tests/test_inheritance.py+9 added
173 unmodified lines
174 '{% endblock %}]{% endfor %}'175 }))176 t = env.from_string('{% extends "master.html" %}{% block item %}{{ item }}{% endblock %}')177 assert t.render(seq=range(5)) == '[0][1][2][3][4]'178179180def test_super_in_scoped_block():181 env = Environment(loader=DictLoader({182 'master.html': '{% for item in seq %}[{% block item scoped %}'183 '{{ item }}{% endblock %}]{% endfor %}'184 }))185 t = env.from_string('{% extends "master.html" %}{% block item %}{{ super() }}|{{ item * 2 }}{% endblock %}')186 assert t.render(seq=range(5)) == '[0|0][1|2][2|4][3|6][4|8]'