- fixed a limitation in the lexer that made ``{{ foo.0.0 }}`` impossible.
+- index based subscribing of variables with a constant value returns an
+ undefined object now instead of raising an index error. This was a bug
+ caused by eager optimizing.
+
Version 2.0
-----------
(codename jinjavitus, released on July 17th 2008)
self.write(', %r)' % node.attr)
def visit_Getitem(self, node, frame):
- # slices or integer subscriptions bypass the getitem
- # method if we can determine that at compile time.
- if isinstance(node.arg, nodes.Slice) or \
- (isinstance(node.arg, nodes.Const) and
- isinstance(node.arg.value, (int, long))):
+ # slices bypass the environment getitem method.
+ if isinstance(node.arg, nodes.Slice):
self.visit(node.node, frame)
self.write('[')
self.visit(node.arg, frame)
:copyright: 2008 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""
+from py.test import raises
+from jinja2 import Template
+from jinja2.exceptions import UndefinedError
test_default_undefined = '''
...
UndefinedError: 'missing' is undefined
'''
+
+
+def test_indexing_gives_undefined():
+ t = Template("{{ var[42].foo }}")
+ raises(UndefinedError, t.render, var=0)