def test_parse(self): template = parse_string("$person.name") # when undefined self.assertEqual(template.render_string(), "") # when did set self.assertEqual(template.render_string(person={"name": "tikubonn"}), "tikubonn")
def test_parse(self): template = parse_string( "<!-- @for $element in $iter --> $element <!-- @endfor -->") # when undefined self.assertEqual(template.render_string(), "") # when (a, b, c) self.assertEqual(template.render_string(iter=["a", "b", "c"]), "abc")
def test_parse1(self): template = parse_string("@if $value true @else false @endif") # when undefined self.assertEqual(template.render_string(), "false") # when true self.assertEqual(template.render_string(value=True), "true") # when false self.assertEqual(template.render_string(value=False), "false")
def test_parse1(self): template = parse_string( "<!-- @if $value --> true <!-- @else --> false <!-- @endif -->") # when undefined self.assertEqual(template.render_string(), "false") # when true self.assertEqual(template.render_string(value=True), "true") # when false self.assertEqual(template.render_string(value=False), "false")
def test_parse(self): template = parse_string("@trim $value") # when undefined self.assertEqual(template.render_string(), "") # when "monaco" self.assertEqual(template.render_string(value="monaco"), "monaco") # when " monaco" self.assertEqual(template.render_string(value=" monaco"), "monaco") # when "monaco " self.assertEqual(template.render_string(value="monaco "), "monaco") # when " monaco " self.assertEqual(template.render_string(value=" monaco "), "monaco")
def test_parse(self): template = parse_string("$name") # when undefined self.assertEqual(template.render_string(), "") # when did set self.assertEqual(template.render_string(name="tikubonn"), "tikubonn")
def test_parse(self): template = parse_string("@join , $iter") # when undefined self.assertEqual(template.render_string(), "") # when (a, b, c) self.assertEqual(template.render_string(iter=["a", "b", "c"]), "a,b,c")
def test_parse(self): template = parse_string("@sanitize $value") # when undefined self.assertEqual(template.render_string(), "") # when html code self.assertEqual(template.render_string(value="<br>"), "<br>")