diff options
author | Armin Ronacher <armin.ronacher@active-4.com> | 2008-06-14 14:19:47 +0200 |
---|---|---|
committer | Armin Ronacher <armin.ronacher@active-4.com> | 2008-06-14 14:19:47 +0200 |
commit | d02fc7db91a3f67f04489ddade7d9387d90eeab1 (patch) | |
tree | 65ebb6b855282e662a9a84e61ae30de1e4b92d3c /jinja2/lexer.py | |
parent | 3e3a9be203c713cd83e0eaa24a58ea394c5eb0a9 (diff) | |
download | jinja2-d02fc7db91a3f67f04489ddade7d9387d90eeab1.tar.gz |
Added example extension that uses the stream filtering and added unittests.
--HG--
branch : trunk
Diffstat (limited to 'jinja2/lexer.py')
-rw-r--r-- | jinja2/lexer.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/jinja2/lexer.py b/jinja2/lexer.py index 108e49c..0597b7a 100644 --- a/jinja2/lexer.py +++ b/jinja2/lexer.py @@ -71,6 +71,13 @@ operator_re = re.compile('(%s)' % '|'.join(re.escape(x) for x in sorted(operators, key=lambda x: -len(x)))) +def count_newlines(value): + """Count the number of newline characters in the string. This is + useful for extensions that filter a stream. + """ + return len(newline_re.findall(value)) + + class Failure(object): """Class that raises a `TemplateSyntaxError` if called. Used by the `Lexer` to specify known errors. |