summaryrefslogtreecommitdiff
path: root/pystache
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2012-05-05 08:35:32 -0700
committerChris Jerdonek <chris.jerdonek@gmail.com>2012-05-05 08:35:32 -0700
commit8b2c78422a26f40f47ac2f2ccfe57d30991ae9d3 (patch)
tree8de405c1e71a936bfc0ef54763b5301cc4889400 /pystache
parent4f85f1f06c3d27683d1fdba563e985fd18c65d9f (diff)
downloadpystache-8b2c78422a26f40f47ac2f2ccfe57d30991ae9d3.tar.gz
More parser simplifications.
Diffstat (limited to 'pystache')
-rw-r--r--pystache/parser.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/pystache/parser.py b/pystache/parser.py
index 446ceb8..3230058 100644
--- a/pystache/parser.py
+++ b/pystache/parser.py
@@ -142,30 +142,27 @@ class Parser(object):
match_index += len(leading_whitespace)
leading_whitespace = ''
+ start_index = end_index
+
if tag_type in ('#', '^'):
# Cache current state.
- state = (tag_type, tag_key, leading_whitespace, end_index, section_key, parsed_template)
+ state = (tag_type, tag_key, end_index, section_key, parsed_template)
states.append(state)
# Initialize new state
- start_index, section_key = end_index, tag_key
- parsed_template = ParsedTemplate()
- content_end_index, parsed_section = None, None
-
+ section_key, parsed_template = tag_key, ParsedTemplate()
continue
- start_index = end_index
-
if tag_type == '/':
if tag_key != section_key:
raise ParsingError("Section end tag mismatch: %s != %s" % (tag_key, section_key))
# Restore previous state with newly found section data.
- content_end_index, parsed_section = match_index, parsed_template
+ parsed_section = parsed_template
- (tag_type, tag_key, leading_whitespace, end_index, section_key, parsed_template) = states.pop()
+ (tag_type, tag_key, end_index, section_key, parsed_template) = states.pop()
node = self._make_section_node(template, tag_type, tag_key, parsed_section,
- end_index, content_end_index)
+ end_index, match_index)
else:
node = self._make_interpolation_node(tag_type, tag_key, leading_whitespace)