Skip to content
Myr

This fixes #368.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent d9599c8 · Browse files · 2 files+16 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+16 added−9 removed

  • other:+16 added−9 removed

2 files+16 added−9 removed

modified:jinja2/testsuite/lexnparse.py+2 added
186 unmodified lines
187 "that needs to be closed is 'for'.")188 assert_error('{% block foo-bar-baz %}',189 "Block names in Jinja have to be valid Python identifiers "190 "and may not contain hypens, use an underscore instead.")191 assert_error('{% unknown_tag %}',192 "Encountered unknown tag 'unknown_tag'.")193194195class SyntaxTestCase(JinjaTestCase):196
178 unmodified lines
modified:jinja2/parser.py+14 added-9 removed
52 unmodified lines
53 def _fail_ut_eof(self, name, end_token_stack, lineno):54 expected = []55 for exprs in end_token_stack:56 expected.extend(map(describe_token_expr, exprs))57 if end_token_stack:58 currently_looking = ' or '.join(57 currently_looking = ' or '.join("'%s'" % describe_token_expr(expr)58 for expr in end_token_stack[-1])59 "'%s'" % describe_token_expr(expr)60 for expr in end_token_stack[-1])61 else:62 currently_looking = None6364 if name is None:65 message = ['Unexpected end of template.']66 else:67 message = ['Encountered unknown tag \'%s\'.' % name]6869 if currently_looking:65 if name is not None and name in expected:66 message.append('You probably made a nesting mistake. Jinja '67 'is expecting this tag, but currently looking '68 'for %s.' % currently_looking)69 else:70 message.append('Jinja was looking for the following tags: '71 '%s.' % currently_looking)70 if name is not None and name in expected:71 message.append('You probably made a nesting mistake. Jinja '72 'is expecting this tag, but currently looking '73 'for %s.' % currently_looking)74 else:75 message.append('Jinja was looking for the following tags: '76 '%s.' % currently_looking)7778 if self._tag_stack:79 message.append('The innermost block that needs to be '80 'closed is \'%s\'.' % self._tag_stack[-1])
802 unmodified lines