Skip to content

Commit

Permalink
section and tag names can include aesthetic whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
defunkt committed Nov 13, 2009
1 parent de25342 commit c63d008
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions examples/complex_view.mustache
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
{{#list}} {{#list}}
<ul> <ul>
{{#item}} {{#item}}
{{#current}} {{# current }}
<li><strong>{{name}}</strong></li> <li><strong>{{name}}</strong></li>
{{/current}} {{/ current }}
{{#link}} {{#link}}
<li><a href="{{url}}">{{name}}</a></li> <li><a href="{{url}}">{{name}}</a></li>
{{/link}} {{/link}}
Expand Down
4 changes: 3 additions & 1 deletion pystache/template.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def compile_regexps(self):
section = r"%(otag)s\#([^\}]*)%(ctag)s\s*(.+?)\s*%(otag)s/\1%(ctag)s" section = r"%(otag)s\#([^\}]*)%(ctag)s\s*(.+?)\s*%(otag)s/\1%(ctag)s"
self.section_re = re.compile(section % tags, re.M|re.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) self.tag_re = re.compile(tag % tags)


def render_sections(self, template, context): def render_sections(self, template, context):
Expand All @@ -54,6 +54,7 @@ def render_sections(self, template, context):
break break


section, section_name, inner = match.group(0, 1, 2) section, section_name, inner = match.group(0, 1, 2)
section_name = section_name.strip()


it = context.get(section_name, None) it = context.get(section_name, None)
replacer = '' replacer = ''
Expand All @@ -77,6 +78,7 @@ def render_tags(self, template, context):
break break


tag, tag_type, tag_name = match.group(0, 1, 2) tag, tag_type, tag_name = match.group(0, 1, 2)
tag_name = tag_name.strip()
func = 'render_' + self.tag_types[tag_type] func = 'render_' + self.tag_types[tag_type]


if hasattr(self, func): if hasattr(self, func):
Expand Down

0 comments on commit c63d008

Please sign in to comment.