Commit bb549161 by Carl Whittaker

Adding tests for negated (empty list) tag, partials in loops not referencing parent values.

parent 6c2d2b05
{{^f}}one{{/f}}, {{ two }}, {{^f}}three{{/f}}{{^t}}, four!{{/t}}
\ No newline at end of file
{{^f}}one{{/f}}, {{ two }}, {{^f}}three{{/f}}{{^t}}, four!{{/t}}{{^empty_list}}, empty list{{/empty_list}}{{^populated_list}}, shouldn't see me{{/populated_list}}
\ No newline at end of file
......@@ -11,3 +11,9 @@ class Inverted(pystache.View):
def two(self):
return 'two'
def empty_list(self):
return []
def populated_list(self):
return ['some_value']
\ No newline at end of file
{{#foo}}{{thing1}} and {{thing2}} and {{outer_thing}}{{/foo}}{{^foo}}Not foo!{{/foo}}
{{#foo}}{{thing1}} and {{thing2}} and {{outer_thing}}{{/foo}}{{^foo}}Not foo!{{/foo}}
\ No newline at end of file
<h1>{{title}}</h1>
{{>inner_partial}}
\ No newline at end of file
{{>inner_partial}}
{{#looping}}
{{>inner_partial}}
{{/looping}}
\ No newline at end of file
......@@ -8,3 +8,6 @@ class TemplatePartial(pystache.View):
def title_bars(self):
return '-' * len(self.title())
def looping(self):
return [{'item': 'one'}, {'item': 'two'}, {'item': 'three'}]
\ No newline at end of file
......@@ -88,7 +88,7 @@ class TestView(unittest.TestCase):
def test_inverted(self):
view = Inverted()
self.assertEquals(view.render(), """one, two, three""")
self.assertEquals(view.render(), """one, two, three, empty list""")
if __name__ == '__main__':
......
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