self.writeline('else:')
self.indent()
+ loop = self.environment._async and 'async for' or 'for'
if node.with_context:
- self.writeline('for event in template.root_render_func('
+ self.writeline('%s event in template.root_render_func('
'template.new_context(context.parent, True, '
- 'locals())):')
+ 'locals())):' % loop)
else:
self.writeline('for event in template._get_default_module()'
'._body_stream:')
if node.with_context:
self.write('make_module(context.parent, True, locals())')
else:
- self.write('module')
+ self.write('_get_default_module()')
if frame.toplevel and not node.target.startswith('_'):
self.writeline('context.exported_vars.discard(%r)' % node.target)
frame.assigned_names.add(node.target)
if node.with_context:
self.write('make_module(context.parent, True)')
else:
- self.write('module')
+ self.write('_get_default_module()')
var_names = []
discarded_names = []
if body_stream is None:
if context.environment._async:
raise RuntimeError('Async mode requires a body stream '
- 'to be passed in.')
+ 'to be passed to a template module. Use '
+ 'the async methods of the API you are '
+ 'using.')
body_stream = list(template.root_render_func(context))
self._body_stream = body_stream
self.__dict__.update(context.get_exported())