intended behavior in all situations however it does not restore the
old behavior where limited assignments to outer scopes was possible.
For more information and a discussion see #641
+- Resolved an issue where `block scoped` would not take advantage of the
+ new scoping rules. In some more exotic cases a variable overriden in a
+ local scope would not make it into a block.
Version 2.9.2
-------------
'StopIteration exception')
def derived(self, locals=None):
- """Internal helper function to create a derived context."""
+ """Internal helper function to create a derived context. This is
+ used in situations where the system needs a new context in the same
+ template that is independent.
+ """
context = new_context(self.environment, self.name, {},
- self.parent, True, None, locals)
- context.vars.update(self.vars)
+ self.get_all(), True, None, locals)
context.eval_ctx = self.eval_ctx
context.blocks.update((k, list(v)) for k, v in iteritems(self.blocks))
return context
t = env.from_string('{% macro x() %}{% block foo %}x{% '
'endblock %}{% endmacro %}{{ x() }}')
assert t.render() == 'x'
+
+ def test_scoped_block(self, env):
+ t = env.from_string('{% set x = 1 %}{% with x = 2 %}{% block y scoped %}'
+ '{{ x }}{% endblock %}{% endwith %}')
+ assert t.render() == '2'