Commit a92a5359 by Heliodor Jalba

Added test for spacing around section tags on a single line. Fixed the problem…

Added test for spacing around section tags on a single line. Fixed the problem indicated by the test: a section's contents were being left trimmed.
parent b9bd807a
......@@ -62,7 +62,7 @@ class Template(object):
'ctag': re.escape(self.ctag)
}
section = r"%(otag)s[\#|^]([^\}]*)%(ctag)s\s*(.+?\s*)%(otag)s/\1%(ctag)s"
section = r"%(otag)s[\#|^]([^\}]*)%(ctag)s(.+?)%(otag)s/\1%(ctag)s"
self.section_re = re.compile(section % tags, re.M|re.S)
tag = r"%(otag)s(#|=|&|!|>|\{)?(.+?)\1?%(ctag)s+"
......
......@@ -75,5 +75,10 @@ class TestPystache(unittest.TestCase):
ret = pystache.render(template, context)
self.assertEquals(ret, """<ul><li>Chris</li><li>Tom</li><li>PJ</li></ul>""")
def test_spacing(self):
template = "first{{#spacing}} second {{/spacing}}third"
ret = pystache.render(template, {"spacing": True})
self.assertEquals(ret, "first second third")
if __name__ == '__main__':
unittest.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