return Undefined
def __setitem__(self, name, value):
- self._stack[-1][name] = value
+ self.current[name] = value
def __delitem__(self, name):
- if name in self._stack[-1]:
- del self._stack[-1][name]
+ if name in self.current:
+ del self.current[name]
def __repr__(self):
tmp = {}
# global namespace
self.globals = namespace is None and DEFAULT_NAMESPACE.copy() \
- or namespace
+ or namespace or {}
# create lexer
self.lexer = Lexer(self)
args += tuple(dyn_args)
elif dyn_kwargs is not None:
kwargs.update(dyn_kwargs)
- if getattr(f, 'jinja_unsafe_call', False):
+ if getattr(f, 'jinja_unsafe_call', False) or \
+ getattr(f, 'alters_data', False):
raise SecurityException('unsafe function %r called' % f.__name__)
return f(*args, **kwargs)
except (StopIteration, ValueError):
raise TemplateSyntaxError('invalid syntax for set', lineno)
ast = self.parse_python(lineno, gen, '(%s)')
- return nodes.Set(lineno, name[1], ast.expr)
+ return nodes.Set(lineno, name[2], ast.expr)
def handle_filter_directive(self, lineno, gen):
"""