Added example extension that uses the stream filtering and added unittests.
--HG--
branch : trunk
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 @@
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.