Commit a15519f4 by Chris Wanstrath

Add {{& blah}} as an alias for {{{ blah }}}

parent 04560aca
......@@ -52,7 +52,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(#|=|!|>|\{)?(.+?)\1?%(ctag)s+"
tag = r"%(otag)s(#|=|&|!|>|\{)?(.+?)\1?%(ctag)s+"
self.tag_re = re.compile(tag % tags)
def render_sections(self, template, context):
......@@ -108,6 +108,7 @@ class Template(object):
return ''
@modifier('{')
@modifier('&')
def render_unescaped(self, tag_name=None, context=None):
"""Render a tag without escaping it."""
return unicode(context.get(tag_name, ''))
......
......@@ -38,6 +38,12 @@ class TestView(unittest.TestCase):
def test_unescaped(self):
self.assertEquals(Unescaped().render(), "<h1>Bear > Shark</h1>")
def test_unescaped_sigil(self):
view = Escaped(template="<h1>{{& thing}}</h1>", context={
'thing': 'Bear > Giraffe'
})
self.assertEquals(view.render(), "<h1>Bear > Giraffe</h1>")
def test_template_partial(self):
self.assertEquals(TemplatePartial().render(), """<h1>Welcome</h1>
Again, Welcome!""")
......
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