summaryrefslogtreecommitdiff
path: root/pystache/parser.py
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2012-05-04 14:54:19 -0700
committerChris Jerdonek <chris.jerdonek@gmail.com>2012-05-04 14:54:19 -0700
commitef3ef4bf927dce83341b05ef61a251c3d450920c (patch)
tree1718c750c2617a308c9838595ba58e3efebffe02 /pystache/parser.py
parent1a9ca1f74acd12f72993cbb7e19ab07b36d7cc18 (diff)
downloadpystache-ef3ef4bf927dce83341b05ef61a251c3d450920c.tar.gz
Refactored some of the parsing logic: delayed template slicing.
Diffstat (limited to 'pystache/parser.py')
-rw-r--r--pystache/parser.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/pystache/parser.py b/pystache/parser.py
index 4851303..b2af35c 100644
--- a/pystache/parser.py
+++ b/pystache/parser.py
@@ -177,10 +177,10 @@ class Parser(object):
including any trailing newlines).
"""
- parsed_section, content_end_index, end_index = \
+ parsed_section, section_end_index, end_index = \
self.parse(template=template, start_index=start_index, section_key=section_key)
- return parsed_section, template[start_index:content_end_index], end_index
+ return parsed_section, section_end_index, end_index
def _handle_tag_type(self, template, parse_tree, tag_type, tag_key, leading_whitespace, end_index):
@@ -205,12 +205,14 @@ class Parser(object):
elif tag_type == '#':
- parsed_section, section_contents, end_index = self._parse_section(template, end_index, tag_key)
- func = engine._make_get_section(tag_key, parsed_section, section_contents, self._delimiters)
+ section_start_index = end_index
+ parsed_section, section_end_index, end_index = self._parse_section(template, end_index, tag_key)
+ func = engine._make_get_section(tag_key, parsed_section, self._delimiters,
+ template, section_start_index, section_end_index)
elif tag_type == '^':
- parsed_section, section_contents, end_index = self._parse_section(template, end_index, tag_key)
+ parsed_section, section_end_index, end_index = self._parse_section(template, end_index, tag_key)
func = engine._make_get_inverse(tag_key, parsed_section)
elif tag_type == '>':