github地址
http://mustache.github.io/
https://github.com/defunkt/pystache
使用:
>>> import pystache>>> print pystache.render('Hi {{person}}!', {'person': 'Mom'})Hi Mom!
has为boolean值时,true则中间的逻辑执行,false则不执行
>>>print(pystache.render("hello {{name}} {{#has}} world {{value}} {{/has}}",{"name": "tingjio","has": False,"value": "mengsio"}))hello tingjio>>>print(pystache.render("hello {{name}} {{#has}} world {{value}} {{/has}}",{"name": "tingjio","has": True,"value": "mengsio"}))hello tingjio world mengsio
has是数组时,循环获取数组的值
>>> print(pystache.render("hello {{name}} {{#has}} world {{child}} " "{{/has}}",{"name": "tingjio","has": [{"child": '1'},{"child": '2'},{"child": '3'},],"value": "mengsio"}))hello tingjio world 1 world 2 world 3
