Commit c63d0084 by Chris Wanstrath

section and tag names can include aesthetic whitespace

parent de25342b
...@@ -2,9 +2,9 @@ ...@@ -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}}
......
...@@ -43,7 +43,7 @@ class Template(object): ...@@ -43,7 +43,7 @@ class Template(object):
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):
...@@ -54,6 +54,7 @@ class Template(object): ...@@ -54,6 +54,7 @@ class Template(object):
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 = ''
...@@ -77,6 +78,7 @@ class Template(object): ...@@ -77,6 +78,7 @@ class Template(object):
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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment