Skip to content

Instantly share code, notes, and snippets.

@rafacv
Created August 13, 2010 07:46
Show Gist options
  • Save rafacv/522505 to your computer and use it in GitHub Desktop.
Save rafacv/522505 to your computer and use it in GitHub Desktop.
Callable bug with Pystache's View
>>> import pystache
>>> from pystache import view
>>>
>>> class Dummy(view.View):
... pass
...
>>> context = {'icecream': lambda flavor: "%s icecream" % flavor, 'title': 'Yummy'}
>>> template = "** {{title}}\n\n {{#icecream}}Strawberry{{/icecream}}"
>>>
>>> context2 = dict(context.items())
>>> context2['icecream'] = True
>>>
>>> dummy = Dummy(template, context)
>>> dummy.render()
u'** Yummy\n\n '
>>> dummy2 = Dummy(template, context2)
>>> dummy2.render()
u'** Yummy\n\n Strawberry'
>>> pystache.render(template, context)
u'** Yummy\n\n Strawberry icecream'
>>> pystache.render(template, context2)
u'** Yummy\n\n Strawberry'
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment