- Block sets are now marked `safe` by default.
- On Python 2 the asciification of ASCII strings can now be disabled with
the `compiler.ascii_str` policy.
+- Tests now no longer accept an arbitrary expression as first argument but
+ a restricted one. This means that you can now properly use multiple
+ tests in one expression without extra parentheses. In particular you can
+ now write ``foo is divisibleby 2 or foo is divisibleby 3``
+ as you would expect.
Version 2.8.2
-------------
'name:and')):
if self.stream.current.test('name:is'):
self.fail('You cannot chain multiple tests with is')
- args = [self.parse_expression()]
+ args = [self.parse_primary()]
else:
args = []
node = nodes.Test(node, name, args, kwargs, dyn_args,
tmpl = env.from_string('{{ 0 is lessthan 1 }}|'
'{{ 1 is lessthan 0 }}')
assert tmpl.render() == 'True|False'
+
+ def test_multiple_tests(self):
+ items = []
+ def matching(x, y):
+ items.append((x, y))
+ return False
+ env = Environment()
+ env.tests['matching'] = matching
+ tmpl = env.from_string("{{ 'us-west-1' is matching "
+ "'(us-east-1|ap-northeast-1)' "
+ "or 'stage' is matching '(dev|stage)' }}")
+ assert tmpl.render() == 'False'
+ assert items == [('us-west-1', '(us-east-1|ap-northeast-1)'),
+ ('stage', '(dev|stage)')]