Commit b00aaf4d by Chris Jerdonek

Merge pull request #27 "Pystache spacing on a single line was wrong"

  From: https://github.com/heliodor/pystache/commit/a92a5359afd67234aa71185a3c8f7bdf43c8d729
  Into: issue_27

This commit fixes the Template class's rendering to comply with the spec's
requirement that sections not alter surrounding whitespace.  A test case
was included.
parents 5f1c034d a92a5359
......@@ -72,7 +72,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