Skip to content

Commit f4ca152

Browse files
committed
Merged branch 'hotfix-v0.5.2-rc.1-mixed-lambda-list' to master.
Fixed issue with list section values containing both lambdas and non-lambdas.
2 parents 8bc8baf + 83b7502 commit f4ca152

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

pystache/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
__all__ = ['render', 'Renderer', 'TemplateSpec']
1212

13-
__version__ = '0.5.2-rc' # Also change in setup.py.
13+
__version__ = '0.5.2-rc.1' # Also change in setup.py.

pystache/renderengine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ def get_section(context):
208208
#
209209
# TODO: should we check the arity?
210210
new_template = element(template)
211-
parsed_template = self._parse(new_template, delimiters=delims)
212-
parts.append(parsed_template.render(context))
211+
new_parsed_template = self._parse(new_template, delimiters=delims)
212+
parts.append(new_parsed_template.render(context))
213213
continue
214214

215215
context.push(element)

pystache/tests/test_context.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,18 +408,18 @@ def test_dot_notation__dict(self):
408408
def test_dot_notation__user_object(self):
409409
name = "foo.bar"
410410
stack = ContextStack({"foo": Attachable(bar="baz")})
411-
self.assertEquals(stack.get(name), "baz")
411+
self.assertEqual(stack.get(name), "baz")
412412

413413
# Works on multiple levels, too
414414
name = "a.b.c.d.e.f.g"
415415
A = Attachable
416416
stack = ContextStack({"a": A(b=A(c=A(d=A(e=A(f=A(g="w00t!"))))))})
417-
self.assertEquals(stack.get(name), "w00t!")
417+
self.assertEqual(stack.get(name), "w00t!")
418418

419419
def test_dot_notation__mixed_dict_and_obj(self):
420420
name = "foo.bar.baz.bak"
421421
stack = ContextStack({"foo": Attachable(bar={"baz": Attachable(bak=42)})})
422-
self.assertEquals(stack.get(name), 42)
422+
self.assertEqual(stack.get(name), 42)
423423

424424
def test_dot_notation__missing_attr_or_key(self):
425425
name = "foo.bar.baz.bak"
@@ -460,11 +460,11 @@ def test_dot_notation__autocall(self):
460460

461461
# When any element in the path is callable, it should be automatically invoked
462462
stack = ContextStack({"foo": Attachable(bar=Attachable(baz=lambda: "Called!"))})
463-
self.assertEquals(stack.get(name), "Called!")
463+
self.assertEqual(stack.get(name), "Called!")
464464

465465
class Foo(object):
466466
def bar(self):
467467
return Attachable(baz='Baz')
468468

469469
stack = ContextStack({"foo": Foo()})
470-
self.assertEquals(stack.get(name), "Baz")
470+
self.assertEqual(stack.get(name), "Baz")

pystache/tests/test_renderengine.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,21 @@ def test_section__lambda__list(self):
517517

518518
self._assert_render(u'<~bar~#bar#>', template, context)
519519

520+
def test_section__lambda__mixed_list(self):
521+
"""
522+
Test a mixed list of lambdas and non-lambdas as a section value.
523+
524+
This test case is equivalent to a test submitted to the Mustache spec here:
525+
526+
https://github.com/mustache/spec/pull/47 .
527+
528+
"""
529+
template = '<{{#lambdas}}foo{{/lambdas}}>'
530+
context = {'foo': 'bar',
531+
'lambdas': [lambda text: "~{{%s}}~" % text, 1]}
532+
533+
self._assert_render(u'<~bar~foo>', template, context)
534+
520535
def test_section__lambda__not_on_context_stack(self):
521536
"""
522537
Check that section lambdas are not pushed onto the context stack.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
# print("Using: version %s of %s" % (repr(dist.__version__), repr(dist)))
7373

7474

75-
VERSION = '0.5.2-rc' # Also change in pystache/__init__.py.
75+
VERSION = '0.5.2-rc.1' # Also change in pystache/__init__.py.
7676

7777
HISTORY_PATH = 'HISTORY.rst'
7878
LICENSE_PATH = 'LICENSE'

0 commit comments

Comments
 (0)