Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

section and tag names can include aesthetic whitespace

  • Loading branch information...
commit c63d008486c7d14b3ee1256724cb82222ab5e383 1 parent de25342
@defunkt defunkt authored
Showing with 5 additions and 3 deletions.
  1. +2 −2 examples/complex_view.mustache
  2. +3 −1 pystache/template.py
View
4 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}}
View
4 pystache/template.py
@@ -43,7 +43,7 @@ def compile_regexps(self):
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 @@ def render_sections(self, template, context):
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 @@ def render_tags(self, template, context):
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):
Please sign in to comment.
Something went wrong with that request. Please try again.