From: Armin Ronacher Date: Wed, 26 Sep 2007 11:16:41 +0000 (+0200) Subject: added new testcase X-Git-Tag: 2.0rc1~266 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9b0545ac54b706e58545bb881d512d705a884c42;p=jinja2.git added new testcase --HG-- branch : trunk --- 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'