From 7eef0a68507d1f01464d9ee980483ba2fca10c28 Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Sat, 5 May 2012 11:42:51 -0700 Subject: Avoid adding spurious empty strings to the parse tree. --- pystache/parser.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'pystache') diff --git a/pystache/parser.py b/pystache/parser.py index 1c6a5ee..99f8d13 100644 --- a/pystache/parser.py +++ b/pystache/parser.py @@ -113,8 +113,9 @@ class Parser(object): match_index = match.start() end_index = match.end() - # Add string contents before the tag. - parsed_template.add(template[start_index:match_index]) + # 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() -- cgit v1.2.1