Commit d8067382 by Chris Jerdonek

Loading of partials now respects the template extension configured on the view:

 * Template._render_partial() now passes self.view.template_extension to
   Loader.load_template().

 * The test case test_examples.test_template_partial_extension now passes.

 * Corrected the expectation of the test case test_simple.test_template_partial_extension.
   It passes under the change to Template._render_partial().

 * Removed trailing white space in test_simple.py.
parent 23feb60d
......@@ -160,7 +160,7 @@ class Template(object):
@modifiers.set('>')
def _render_partial(self, template_name):
from pystache import Loader
markup = Loader().load_template(template_name, self.view.template_path, encoding=self.view.template_encoding)
markup = Loader().load_template(template_name, self.view.template_path, encoding=self.view.template_encoding, extension=self.view.template_extension)
template = Template(markup, self.view)
return template.render()
......
......@@ -7,14 +7,14 @@ from examples.template_partial import TemplatePartial
from examples.simple import Simple
class TestSimple(unittest.TestCase):
def test_simple_render(self):
self.assertEqual('herp', pystache.Template('{{derp}}', {'derp': 'herp'}).render())
def test_nested_context(self):
view = NestedContext()
self.assertEquals(pystache.Template('{{#foo}}{{thing1}} and {{thing2}} and {{outer_thing}}{{/foo}}{{^foo}}Not foo!{{/foo}}', view).render(), "one and foo and two")
def test_looping_and_negation_context(self):
view = ComplexView()
self.assertEquals(pystache.Template('{{#item}}{{header}}: {{name}} {{/item}}{{^item}} Shouldnt see me{{/item}}', view).render(), "Colors: red Colors: green Colors: blue ")
......@@ -22,28 +22,29 @@ class TestSimple(unittest.TestCase):
def test_empty_context(self):
view = ComplexView()
self.assertEquals(pystache.Template('{{#empty_list}}Shouldnt see me {{/empty_list}}{{^empty_list}}Should see me{{/empty_list}}', view).render(), "Should see me")
def test_callables(self):
view = Lambdas()
self.assertEquals(pystache.Template('{{#replace_foo_with_bar}}foo != bar. oh, it does!{{/replace_foo_with_bar}}', view).render(), 'bar != bar. oh, it does!')
def test_rendering_partial(self):
view = TemplatePartial()
self.assertEquals(pystache.Template('{{>inner_partial}}', view).render(), 'Again, Welcome!')
self.assertEquals(pystache.Template('{{#looping}}{{>inner_partial}} {{/looping}}', view).render(), '''Again, Welcome! Again, Welcome! Again, Welcome! ''')
def test_non_existent_value_renders_blank(self):
view = Simple()
self.assertEquals(pystache.Template('{{not_set}} {{blank}}', view).render(), ' ')
def test_template_partial_extension(self):
view = TemplatePartial()
view.template_extension = 'txt'
self.assertEquals(view.render(), """Welcome
-------
Again, Welcome!
## Again, Welcome! ##
""")
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