Commit 804c8712 by Chris Jerdonek

Added two rendering test cases re: sections.

The two test cases test, respectively, (1) context precedence and
(2) that section output not be rendered.  The two test cases were
originally proposed for inclusion in the Mustache spec test cases
in mustache/spec issues #31 and #32:

* https://github.com/mustache/spec/pull/31
* https://github.com/mustache/spec/pull/32
parent 883c9efc
......@@ -317,6 +317,24 @@ class RenderTests(unittest.TestCase):
self._assert_render(expected, '{{=$ $=}} {{foo}} ')
self._assert_render(expected, '{{=$ $=}} {{foo}} $={{ }}=$') # was yielding u' '.
def test_section__output_not_interpolated(self):
"""
Check that rendered section output is not interpolated.
"""
template = '{{#section}}{{template}}{{/section}}: {{planet}}'
context = {'section': True, 'template': '{{planet}}', 'planet': 'Earth'}
self._assert_render(u'{{planet}}: Earth', template, context)
def test_section__context_precedence(self):
"""
Check that items higher in the context stack take precedence.
"""
template = '{{entree}} : {{#vegetarian}}{{entree}}{{/vegetarian}}'
context = {'entree': 'chicken', 'vegetarian': {'entree': 'beans and rice'}}
self._assert_render(u'chicken : beans and rice', template, context)
def test_sections__nested_truthy(self):
"""
Check that "nested truthy" sections get rendered.
......
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