diff options
author | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-05-04 14:29:09 -0700 |
---|---|---|
committer | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-05-04 14:29:09 -0700 |
commit | 661b3ecd9a358ae0095949bde832b063568a294c (patch) | |
tree | d4df76e3c106f352f45f7e7a7dbe7cc4e86136fc | |
parent | 8bc8baf31ae4869df1ca0ef3b9c8837d0a075d9d (diff) | |
download | pystache-661b3ecd9a358ae0095949bde832b063568a294c.tar.gz |
Fixed an issue with list section values mixing lambdas and non-lambdas.
-rw-r--r-- | pystache/renderengine.py | 4 | ||||
-rw-r--r-- | pystache/tests/test_renderengine.py | 15 |
2 files changed, 17 insertions, 2 deletions
diff --git a/pystache/renderengine.py b/pystache/renderengine.py index e1d57e4..bdbb30a 100644 --- a/pystache/renderengine.py +++ b/pystache/renderengine.py @@ -208,8 +208,8 @@ class RenderEngine(object): # # TODO: should we check the arity? new_template = element(template) - parsed_template = self._parse(new_template, delimiters=delims) - parts.append(parsed_template.render(context)) + new_parsed_template = self._parse(new_template, delimiters=delims) + parts.append(new_parsed_template.render(context)) continue context.push(element) diff --git a/pystache/tests/test_renderengine.py b/pystache/tests/test_renderengine.py index d7f6bf7..b13e246 100644 --- a/pystache/tests/test_renderengine.py +++ b/pystache/tests/test_renderengine.py @@ -517,6 +517,21 @@ class RenderTests(unittest.TestCase, AssertStringMixin): self._assert_render(u'<~bar~#bar#>', template, context) + def test_section__lambda__mixed_list(self): + """ + Test a mixed list of lambdas and non-lambdas as a section value. + + This test case is equivalent to a test submitted to the Mustache spec here: + + https://github.com/mustache/spec/pull/47 . + + """ + template = '<{{#lambdas}}foo{{/lambdas}}>' + context = {'foo': 'bar', + 'lambdas': [lambda text: "~{{%s}}~" % text, 1]} + + self._assert_render(u'<~bar~foo>', template, context) + def test_section__lambda__not_on_context_stack(self): """ Check that section lambdas are not pushed onto the context stack. |