diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-10-25 13:03:44 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-10-25 13:03:44 -0400 |
commit | 94b231f7b6175a38e97ff2555a4553bfa0b58389 (patch) | |
tree | 66b25586ebd052a8e07ea21d7173d87764e4ec81 /coverage/templite.py | |
parent | 62db82f7dff57af3877f36eb08938f3f664a3687 (diff) | |
download | python-coveragepy-git-94b231f7b6175a38e97ff2555a4553bfa0b58389.tar.gz |
Templite now allows comments within curly-hash markers.
Diffstat (limited to 'coverage/templite.py')
-rw-r--r-- | coverage/templite.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/coverage/templite.py b/coverage/templite.py index 23c805b1..3b2efebd 100644 --- a/coverage/templite.py +++ b/coverage/templite.py @@ -18,6 +18,10 @@ class Templite(object): {% for var in list %}...{% endfor %} + Comments are within curly-hash markers:: + + {# This will be ignored #} + Construct a Templite with the template text, then use `render` against a dictionary context to create a finished string. @@ -61,6 +65,8 @@ class Templite(object): def _prepare(self, text): """Convert Django-style data references into Python-native ones.""" + # Remove comments. + text = re.sub(r"(?s){#.*?#}", "", text) # Pull out loops. text = re.sub( r"(?s){% for ([a-z0-9_]+) in ([a-z0-9_.|]+) %}(.*?){% endfor %}", |