summaryrefslogtreecommitdiff
path: root/pystache/parser.py
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2012-05-05 06:53:52 -0700
committerChris Jerdonek <chris.jerdonek@gmail.com>2012-05-05 06:53:52 -0700
commit2de83f87b16edad7fa028e56adf08548fa41a777 (patch)
tree3e47a72820f9869d956a62a096a509c0b6febadc /pystache/parser.py
parentce1b81b1a5951c0ea34c4f8251ada3573af9c691 (diff)
downloadpystache-2de83f87b16edad7fa028e56adf08548fa41a777.tar.gz
Refactoring parser: removed a local variable (index) from parse().
Diffstat (limited to 'pystache/parser.py')
-rw-r--r--pystache/parser.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/pystache/parser.py b/pystache/parser.py
index 9066c54..b573138 100644
--- a/pystache/parser.py
+++ b/pystache/parser.py
@@ -97,12 +97,11 @@ class Parser(object):
"""
parse_tree = []
- index = start_index
content_end_index, parsed_section = None, None
while True:
- match = self._template_re.search(template, index)
+ match = self._template_re.search(template, start_index)
if match is None:
break
@@ -110,7 +109,7 @@ class Parser(object):
match_index = match.start()
end_index = match.end()
- before_tag = template[index : match_index]
+ before_tag = template[start_index : match_index]
parse_tree.append(before_tag)
@@ -149,9 +148,9 @@ class Parser(object):
return end_index, match_index, ParsedTemplate(parse_tree)
if tag_type in ('#', '^'):
- index, content_end_index, parsed_section = self.parse(template, end_index, tag_key)
+ start_index, content_end_index, parsed_section = self.parse(template, end_index, tag_key)
else:
- index = end_index
+ start_index = end_index
# Variable index is now the next character to process.
node = self._make_node(template, tag_type, tag_key, leading_whitespace,
@@ -159,7 +158,7 @@ class Parser(object):
parse_tree.append(node)
# Save the rest of the template.
- parse_tree.append(template[index:])
+ parse_tree.append(template[start_index:])
return ParsedTemplate(parse_tree)