From 9b0545ac54b706e58545bb881d512d705a884c42 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Wed, 26 Sep 2007 13:16:41 +0200 Subject: [PATCH] added new testcase --HG-- branch : trunk --- jinja/parser.py | 5 ++++- tests/test_parser.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/jinja/parser.py b/jinja/parser.py index bc2960c..c31c11b 100644 --- a/jinja/parser.py +++ b/jinja/parser.py @@ -932,12 +932,15 @@ class Parser(object): def ensure(expr): if not expr: raise TemplateSyntaxError('invalid syntax for function ' - 'declaration', token.lineno, + 'call expression', token.lineno, self.filename) while self.stream.current.type != 'rparen': if require_comma: self.stream.expect('comma') + # support for trailing comma + if self.stream.current.type == 'rparen': + break if self.stream.current.type == 'mul': ensure(dyn_args is None and dyn_kwargs is None) self.stream.next() diff --git a/tests/test_parser.py b/tests/test_parser.py index 1c8851d..f6527b6 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -42,6 +42,11 @@ SMARTY_SYNTAX = '''\ BALANCING = '''{{{'foo':'bar'}.foo}}''' +STARTCOMMENT = '''{# foo comment +and bar comment #} +{% macro blub() %}foo{% endmacro %} +{{ blub() }}''' + def test_no_variable_block(): env = Environment('{%', '%}', None, None) @@ -81,3 +86,8 @@ def test_smarty_syntax(): def test_balancing(env): tmpl = env.from_string(BALANCING) assert tmpl.render() == 'bar' + + +def test_start_comment(env): + tmpl = env.from_string(STARTCOMMENT) + assert tmpl.render().strip() == 'foo' -- 2.26.2