From 37b4e3dc6488943736535a7753b2a7f3b16e8d40 Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Sat, 5 May 2012 17:41:41 -0700 Subject: Reduced the number of elements in the parse tree. --- pystache/parser.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'pystache') 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 ('#', '^'): -- cgit v1.2.1