self.visit(node.template, frame)
self.write(', %r).' % self.name)
if node.with_context:
- self.write('make_module%s(context.parent, True)'
- % (self.environment.is_async and '_async' or ''))
+ self.write('make_module%s(context.parent, True, %s)'
+ % (self.environment.is_async and '_async' or '',
+ self.dump_local_context(frame)))
elif self.environment.is_async:
self.write('_get_default_module_async()')
else:
{{ outer("FOO") }}
""")
assert t.render().strip() == '(FOO)'
+
+ def test_import_from_with_context(self):
+ env = Environment(loader=DictLoader({
+ 'a': '{% macro x() %}{{ foobar }}{% endmacro %}',
+ }))
+ t = env.from_string('{% set foobar = 42 %}{% from "a" '
+ 'import x with context %}{{ x() }}')
+ assert t.render() == '42'