From f626c8e2ab8354aea6f5f83803b8f189cf43e866 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Fri, 23 Mar 2007 16:13:10 +0100 Subject: [PATCH] [svn] some small fixes for the jinja release --HG-- branch : trunk --- Makefile | 2 +- jinja/lexer.py | 7 ++++--- jinja/parser.py | 9 +++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index eb6d073..8fcff87 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ documentation: @(cd docs; ./generate.py) webpage: - @(cd www; ./generate.py) + @(cd ../www; ./generate.py) release: @(python2.3 setup.py release bdist_egg; python2.4 setup.py release bdist_egg; python2.5 setup.py release bdist_egg sdist) diff --git a/jinja/lexer.py b/jinja/lexer.py index ed5e341..d419c03 100644 --- a/jinja/lexer.py +++ b/jinja/lexer.py @@ -133,9 +133,10 @@ class Lexer(object): def tokeniter(self, source): """ This method tokenizes the text and returns the tokens in a generator. - Normally it's a better idea to use the `tokenize` function which - returns a `TokenStream` but in some situations it can be useful - to use this function since it can be marginally faster. + Use this method if you just want to tokenize a template. The output + you get is not compatible with the input the jinja parser wants. The + parser uses the `tokenize` function with returns a `TokenStream` with + some escaped tokens. """ source = type(source)('\n').join(source.splitlines()) pos = 0 diff --git a/jinja/parser.py b/jinja/parser.py index 5994fb8..e447733 100644 --- a/jinja/parser.py +++ b/jinja/parser.py @@ -582,7 +582,16 @@ class Parser(object): # template syntax error. if data in self.directives: node = self.directives[data](lineno, gen) + # directive or endtag found, give a proper error message + elif data in self.directives or \ + not data.endswith('_') and data.startswith('end'): + raise TemplateSyntaxError('unexpected directive %r' % + str(data), lineno, + self.filename) + # keyword or unknown name with trailing slash else: + if data.endswith('_'): + data = data[:-1] raise TemplateSyntaxError('unknown directive %r' % str(data), lineno, self.filename) -- 2.26.2