Commit 12d0039d by Chris Jerdonek

Merge pull request #45 (3) "Adding failing test showing callable..."

From: https://github.com/jakearchibald/pystache/commit/1609163fa0c1fe09f7ece8d87be97f730883de06
Into: issue_46

Adds a failing unit test for issue #46 (and another for a standard lambda case).

Conflicts:
	tests/test_pystache.py
parents 4ce9bf1d 1609163f
...@@ -80,6 +80,3 @@ class TestPystache(unittest.TestCase): ...@@ -80,6 +80,3 @@ class TestPystache(unittest.TestCase):
template = "first{{#spacing}} second {{/spacing}}third" template = "first{{#spacing}} second {{/spacing}}third"
ret = pystache.render(template, {"spacing": True}) ret = pystache.render(template, {"spacing": True})
self.assertEquals(ret, "first second third") self.assertEquals(ret, "first second third")
if __name__ == '__main__':
unittest.main()
...@@ -101,3 +101,19 @@ class TemplateTestCase(unittest.TestCase): ...@@ -101,3 +101,19 @@ class TemplateTestCase(unittest.TestCase):
context = {'test': '{{#hello}}'} context = {'test': '{{#hello}}'}
actual = template.render(context) actual = template.render(context)
self.assertEquals(actual, '{{#hello}}') self.assertEquals(actual, '{{#hello}}')
def test_render__section__lambda(self):
template = Template('{{#test}}Mom{{/test}}')
context = {'test': (lambda text: 'Hi %s' % text)}
actual = template.render(context)
self.assertEquals(actual, 'Hi Mom')
def test_render__section__lambda__tag_in_output(self):
"""
Check that callable output isn't treated as a template string (issue #46).
"""
template = Template('{{#test}}Mom{{/test}}')
context = {'test': (lambda text: '{{hi}} %s' % text)}
actual = template.render(context)
self.assertEquals(actual, '{{hi}} Mom')
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