貌似"字符串模板"这个术语不太准确。。。。
a = {'name':'World'}
str = 'Hello %(name)s!'
print str%a # Hello World!
总感觉直接用ejs之类的模板系统太重了。。。有没有轻量化一些的解决方案
在nodejs里,这种模板是如此之多 比较有名的是mustache https://github.com/janl/mustache.js ,以及他的强化版:handlebars http://handlebarsjs.com/
检索一下,会有很多
下面都是 atpl dust eco ect ejs haml haml-coffee handlebars hogan jade jazz jqtpl JUST liquor lodash mustache nunjucks QEJS ractive swig templayed toffee underscore walrus whiskers
— —。。。大家还没明白我的意思......我是觉得这样的模板系统太重了......有没有一些微量级的解决方案,我不是想要一个html模板......只是要在字符串中插入一些内容而已......
有的
看http://www.csdn.net/article/2015-09-15/2825708-7-reasons-to-upgrade-to-node-v4?utm_source=tuicool
《升级到Node V4的七个理由 支持大量ES6特性》
Node V4就有增加模板字符串功能