Commit 90ae7cb4 by Chris Wanstrath

Ensure we're dealing with strings, always

parent 7fdebd3e
## 0.1.1 (2009-11-12)
* Ensure we're dealing with strings, always
## 0.1.0 (2009-11-12)
* First release
......@@ -94,7 +94,7 @@ class Template(object):
@modifier(None)
def render_tag(self, tag_name, context):
"""Given a tag name and context, finds, escapes, and renders the tag."""
return cgi.escape(context.get(tag_name, ''))
return cgi.escape(str(context.get(tag_name, '')))
@modifier('!')
def render_comment(self, tag_name=None, context=None):
......
......@@ -35,6 +35,15 @@ class TestPystache(unittest.TestCase):
ret = pystache.render(template, { 'set': True })
self.assertEquals(ret, "Ready set go!")
def test_non_strings(self):
template = "{{#stats}}({{key}} & {{value}}){{/stats}}"
stats = []
stats.append({'key': 123, 'value': ['something']})
stats.append({'key': u"chris", 'value': 0.900})
ret = pystache.render(template, { 'stats': stats })
self.assertEquals(ret, """(123 & ['something'])(chris & 0.9)""")
def test_sections(self):
template = """
<ul>
......
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