def test_each_node_inside_if(self): tmpl = t('{% if var < 5 %}{% each q %}{{_}}{%end%}{%end%}') self.assertEquals( tmpl.render({'var': 3, 'q': range(3)}), '012' ) self.assertEqual( tmpl.render({'var': 9, 'q': range(3)}), '' )
def test_if_node_inside_each(self): tmpl = t('{% each var %}{% if _ < t %}{{_}}{%end%}{%end%}') self.assertEquals( tmpl.render({'t': 3, 'var': range(5)}), '012' ) self.assertEquals( tmpl.render({'t': 0, 'var': range(5)}), '' )
def test_text_node(self): tmpl = t('123') self.assertEquals(tmpl.render({}), '123')
def test_if_node(self): tmpl = t('{%if a < 5 %}1{%end%}') self.assertEquals(tmpl.render({'a': 3}), '1') self.assertEquals(tmpl.render({'a': 9}), '')
def test_each_node(self): tmpl = t('{%each var%}{{_}}{%end%}') self.assertEquals(tmpl.render({'var': range(3)}), '012')
def test_var_node(self): tmpl = t('{{var}}') self.assertEquals(tmpl.render({'var': 'test'}), 'test')