Commit e822dab9 by Chris Wanstrath

kwargify pystache.render()

parent a65d3987
from pystache.template import Template
def render(template, context={}):
def render(template, context={}, **kwargs):
context = context.copy()
for key in kwargs:
context[key] = kwargs[key]
return Template(template, context).render()
......@@ -6,6 +6,10 @@ class TestPystache(unittest.TestCase):
ret = pystache.render("Hi {{thing}}!", { 'thing': 'world' })
self.assertEquals(ret, "Hi world!")
def test_kwargs(self):
ret = pystache.render("Hi {{thing}}!", thing='world')
self.assertEquals(ret, "Hi world!")
def test_less_basic(self):
template = "It's a nice day for {{beverage}}, right {{person}}?"
ret = pystache.render(template, { 'beverage': 'soda', 'person': 'Bob' })
......
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