From 661b3ecd9a358ae0095949bde832b063568a294c Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Fri, 4 May 2012 14:29:09 -0700 Subject: Fixed an issue with list section values mixing lambdas and non-lambdas. --- pystache/renderengine.py | 4 ++-- pystache/tests/test_renderengine.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'pystache') 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. -- cgit v1.2.1