summaryrefslogtreecommitdiff
path: root/pystache
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2012-05-05 17:41:41 -0700
committerChris Jerdonek <chris.jerdonek@gmail.com>2012-05-05 17:41:41 -0700
commit37b4e3dc6488943736535a7753b2a7f3b16e8d40 (patch)
tree25ef8d2e6bfc291f18bf83c66d737bd1456a98f4 /pystache
parentc8a1f2e13c6e483e992cdf5c78e6c9940331e791 (diff)
downloadpystache-37b4e3dc6488943736535a7753b2a7f3b16e8d40.tar.gz
Reduced the number of elements in the parse tree.
Diffstat (limited to 'pystache')
-rw-r--r--pystache/parser.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/pystache/parser.py b/pystache/parser.py
index 9bfc30c..ad3ee30 100644
--- a/pystache/parser.py
+++ b/pystache/parser.py
@@ -231,10 +231,6 @@ class _Parser(object):
match_index = match.start()
end_index = match.end()
- # Avoid adding spurious empty strings to the parse tree.
- if start_index != match_index:
- parsed_template.add(template[start_index:match_index])
-
matches = match.groupdict()
# Normalize the matches dictionary.
@@ -259,10 +255,13 @@ class _Parser(object):
if end_index < len(template):
end_index += template[end_index] == '\n' and 1 or 0
elif leading_whitespace:
- parsed_template.add(leading_whitespace)
match_index += len(leading_whitespace)
leading_whitespace = ''
+ # Avoid adding spurious empty strings to the parse tree.
+ if start_index != match_index:
+ parsed_template.add(template[start_index:match_index])
+
start_index = end_index
if tag_type in ('#', '^'):