args, kwargs, dyn_args, dyn_kwargs = self.parse_call(None)
elif self.stream.current.type in ('name', 'string', 'integer',
'float', 'lparen', 'lbracket',
- 'lbrace'):
+ 'lbrace') and not \
+ self.stream.current.test_any('name:else', 'name:or',
+ 'name:and'):
+ if self.stream.current.test('name:is'):
+ self.fail('You cannot chain multiple tests with is')
args = [self.parse_expression()]
else:
args = []
str(const), str(const).lower(), str(const).upper()
))
assert tmpl.render() == '%s|%s|' % (const, const)
+
+
+def test_test_chaining(env):
+ raises(TemplateSyntaxError, env.from_string, '{{ foo is string is sequence }}')
+ env.from_string('{{ 42 is string or 42 is number }}').render() == 'True'
for env in Environment(), SandboxedEnvironment():
tmpl = env.from_string('{{ foo.items() }}')
assert tmpl.render(foo={'items': 42}) == "[('items', 42)]"
- tmpl = env.from_string('{{ foo|attr("items") }}')
+ tmpl = env.from_string('{{ foo|attr("items")() }}')
assert tmpl.render(foo={'items': 42}) == "[('items', 42)]"
tmpl = env.from_string('{{ foo["items"] }}')
assert tmpl.render(foo={'items': 42}) == '42'