Skip to content
Myr

simplified from imports

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 dc02b64 · Browse files · 2 files+22 added−3 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+22 added−3 removed

  • other:+22 added−3 removed

2 files+22 added−3 removed

modified:jinja2/compiler.py+21 added-2 removed
839 unmodified lines
840 if node.with_context:841 self.write('make_module(context.parent, True)')842 else:843 self.write('module')844845 var_names = []846 discarded_names = []847 for name in node.names:848 if isinstance(name, tuple):849 name, alias = name850 else:
8 unmodified lines
859 (alias, 'the template %r does not export '860 'the requested name ' + repr(name), name))861 self.outdent()862 if frame.toplevel:860 self.writeline('context.vars[%r] = l_%s' % (alias, alias))863 var_names.append(alias)864 if not alias.startswith('__'):862 self.writeline('context.exported_vars.discard(%r)' % alias)865 discarded_names.append(alias)866867 if var_names:868 if len(var_names) == 1:869 name = var_names[0]870 self.writeline('context.vars[%r] = l_%s' % (name, name))871 else:872 self.writeline('context.vars.update({%s})' % ', '.join(873 '%r: l_%s' % (name, name) for name in var_names874 ))875 if discarded_names:876 if len(discarded_names) == 1:877 self.writeline('context.exported_vars.discard(%r)' %878 discarded_names[0])879 else:880 self.writeline('context.exported_vars.difference_'881 'update((%s))' % ', '.join(map(repr, discarded_names)))882883 def visit_For(self, node, frame):884 # when calculating the nodes for the inner frame we have to exclude885 # the iterator contents from it886 children = node.iter_child_nodes(exclude=('iter',))
560 unmodified lines
modified:jinja2/parser.py+1 added-1 removed
7 unmodified lines
8 :copyright: 2008 by Armin Ronacher.9 :license: BSD, see LICENSE for more details.10"""11from jinja2 import nodes12from jinja2.exceptions import TemplateSyntaxError12from jinja2.exceptions import TemplateSyntaxError, TemplateAssertionError131415_statement_keywords = frozenset(['for', 'if', 'block', 'extends', 'print',16 'macro', 'include', 'from', 'import',
739 unmodified lines