def test_template_partial_extension(self): view = TemplatePartial() view.template_extension = 'txt' assert_strings(self, view.render(), u"""Welcome ------- ## Again, Welcome! ##""")
def test_partial_in_partial_has_access_to_grand_parent_context(self): renderer = Renderer(search_dirs=EXAMPLES_DIR) view = TemplatePartial(renderer=renderer) view.template = '''{{>partial_in_partial}}''' actual = renderer.render(view, {'prop': 'derp'}) self.assertEqual(actual, 'Hi derp!')
def test_partial_in_partial_has_access_to_grand_parent_context(self): view = TemplatePartial(context = {'prop': 'derp'}) view.template = '''{{>partial_in_partial}}''' self.assertEquals(view.render(), 'Hi derp!') def test_existential_list(self): self.assertEquals(MaybeEmpty([{"name":"this"},{"name":"that"}]).render(), "<h1>Things</h1><ul><li>this</li><li>that</li></ul>") self.assertEquals(MaybeEmpty([]).render(), "")
def test_template_partial_extension(self): view = TemplatePartial() view.template_extension = 'txt' self.assertEquals(view.render(), """Welcome ------- Again, Welcome! """)
def test_partial_in_partial_has_access_to_grand_parent_context(self): renderer = Renderer(search_dirs=EXAMPLES_DIR) view = TemplatePartial(renderer=renderer) view.template = """{{>partial_in_partial}}""" actual = renderer.render(view, {"prop": "derp"}) self.assertEqual(actual, "Hi derp!")
def test_rendering_partial(self): renderer = Renderer(search_dirs=EXAMPLES_DIR) view = TemplatePartial(renderer=renderer) view.template = '{{>inner_partial}}' actual = renderer.render(view) self.assertString(actual, u'Again, Welcome!') view.template = '{{#looping}}{{>inner_partial}} {{/looping}}' actual = renderer.render(view) self.assertString(actual, u"Again, Welcome! Again, Welcome! Again, Welcome! ")
def test_template_partial_extension(self): view = TemplatePartial() view.template_extension = "txt" self.assertEquals( view.render(), """Welcome ------- ## Again, Welcome! ## """, )
def test_template_partial_extension(self): """ Side note: From the spec-- Partial tags SHOULD be treated as standalone when appropriate. In particular, this means that trailing newlines should be removed. """ view = TemplatePartial() view.template_extension = 'txt' assert_strings(self, view.render(), u"""Welcome ------- ## Again, Welcome! ##""")
def test_template_partial_extension(self): renderer = Renderer(search_dirs=EXAMPLES_DIR, file_extension='txt') view = TemplatePartial(renderer=renderer) actual = renderer.render(view) self.assertString(actual, u"""Welcome ------- ## Again, Welcome! ##""")
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_rendering_partial(self): view = TemplatePartial() view.template = '{{>inner_partial}}' self.assertEquals(view.render(), 'Again, Welcome!') view.template = '{{#looping}}{{>inner_partial}} {{/looping}}' self.assertEquals(view.render(), '''Again, Welcome! Again, Welcome! Again, Welcome! ''')
def test_template_partial_extension(self): """ Side note: From the spec-- Partial tags SHOULD be treated as standalone when appropriate. In particular, this means that trailing newlines should be removed. """ renderer = Renderer(search_dirs=EXAMPLES_DIR, file_extension='txt') view = TemplatePartial(renderer=renderer) actual = renderer.render(view) self.assertString(actual, u"""Welcome ------- ## Again, Welcome! ##""")
def test_partial_in_partial_has_access_to_grand_parent_context(self): view = TemplatePartial(context = {'prop': 'derp'}) view.template = '''{{>partial_in_partial}}''' self.assertEquals(view.render(), 'Hi derp!')
def test_template_partial(self): self.assertEquals(TemplatePartial().render(), """<h1>Welcome</h1> Again, Welcome!""")
def test_partial_in_partial_has_access_to_grand_parent_context(self): view = TemplatePartial(context={"prop": "derp"}) view.template = """{{>partial_in_partial}}""" self.assertEquals(view.render(), "Hi derp!")
def test_template_partial(self): renderer = Renderer(search_dirs=EXAMPLES_DIR) actual = renderer.render(TemplatePartial(renderer=renderer)) self.assertString(actual, u"""<h1>Welcome</h1> Again, Welcome!""")