summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wanstrath <chris@ozmm.org>2009-11-12 22:02:02 -0800
committerChris Wanstrath <chris@ozmm.org>2009-11-12 22:02:02 -0800
commitc63d008486c7d14b3ee1256724cb82222ab5e383 (patch)
tree096f43565b3e6dd67b51b72aada3065be4ade4e7
parentde25342bb240199b9a517ce89f1867d6cf6d4f1d (diff)
downloadpystache-c63d008486c7d14b3ee1256724cb82222ab5e383.tar.gz
section and tag names can include aesthetic whitespace
-rw-r--r--examples/complex_view.mustache4
-rw-r--r--pystache/template.py4
2 files changed, 5 insertions, 3 deletions
diff --git a/examples/complex_view.mustache b/examples/complex_view.mustache
index 64dcb64..5317b2f 100644
--- a/examples/complex_view.mustache
+++ b/examples/complex_view.mustache
@@ -2,9 +2,9 @@
{{#list}}
<ul>
{{#item}}
- {{#current}}
+ {{# current }}
<li><strong>{{name}}</strong></li>
- {{/current}}
+ {{/ current }}
{{#link}}
<li><a href="{{url}}">{{name}}</a></li>
{{/link}}
diff --git a/pystache/template.py b/pystache/template.py
index 27192d6..56a717a 100644
--- a/pystache/template.py
+++ b/pystache/template.py
@@ -43,7 +43,7 @@ class Template(object):
section = r"%(otag)s\#([^\}]*)%(ctag)s\s*(.+?)\s*%(otag)s/\1%(ctag)s"
self.section_re = re.compile(section % tags, re.M|re.S)
- tag = r"%(otag)s(#|=|!|>|\{)?\s*(.+?)\s*\1?%(ctag)s+"
+ tag = r"%(otag)s(#|=|!|>|\{)?(.+?)\1?%(ctag)s+"
self.tag_re = re.compile(tag % tags)
def render_sections(self, template, context):
@@ -54,6 +54,7 @@ class Template(object):
break
section, section_name, inner = match.group(0, 1, 2)
+ section_name = section_name.strip()
it = context.get(section_name, None)
replacer = ''
@@ -77,6 +78,7 @@ class Template(object):
break
tag, tag_type, tag_name = match.group(0, 1, 2)
+ tag_name = tag_name.strip()
func = 'render_' + self.tag_types[tag_type]
if hasattr(self, func):