Example #1
0
    def test_template_partial_extension(self):
        view = TemplatePartial()
        view.template_extension = 'txt'
        assert_strings(self, view.render(), u"""Welcome
-------

## Again, Welcome! ##""")
Example #2
0
    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!')
Example #4
0
    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(), "")
Example #5
0
    def test_template_partial_extension(self):
        view = TemplatePartial()
        view.template_extension = 'txt'
        self.assertEquals(view.render(), """Welcome
-------

Again, Welcome!
""")
Example #6
0
    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!')
Example #7
0
    def test_template_partial_extension(self):
        view = TemplatePartial()
        view.template_extension = 'txt'
        self.assertEquals(view.render(), """Welcome
-------

Again, Welcome!
""")
Example #8
0
    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! ")
Example #10
0
    def test_template_partial_extension(self):
        view = TemplatePartial()
        view.template_extension = "txt"
        self.assertEquals(
            view.render(),
            """Welcome
-------

## Again, Welcome! ##

""",
        )
Example #11
0
    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! ")
Example #12
0
    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! ##""")
Example #13
0
    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! ##""")
Example #14
0
    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! ''')
Example #15
0
    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! ''')
Example #16
0
    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! ##""")
Example #17
0
 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!')
Example #18
0
    def test_template_partial(self):
        self.assertEquals(TemplatePartial().render(), """<h1>Welcome</h1>
Again, Welcome!""")
Example #19
0
 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!")
Example #20
0
    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!""")
Example #21
0
 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!')