关于最好的模板语言

2010 年 7 月 20 日
 Livid
目前用过 Django 和 Tornado 的,总是感觉在一些小细节上不太满意。

大家有更好的推荐么?
22806 次点击
所在节点    Python
73 条回复
remus
2011 年 6 月 7 日
zhangkaixuan
2011 年 6 月 21 日
正在往php+drupal攀爬
island205
2011 年 8 月 9 日
mustache
lenmore
2011 年 8 月 9 日
jinja2 +1
wong2
2011 年 11 月 10 日
iwege
2011 年 11 月 10 日
underscore 自带的template ,js的,很灵活很小巧,很适合前端...
iwege
2011 年 11 月 10 日
// By default, Underscore uses ERB-style template delimiters, change the
// following template settings to use alternative delimiters.
_.templateSettings = {
evaluate : /<%([\s\S]+?)%>/g,
interpolate : /<%=([\s\S]+?)%>/g,
escape : /<%-([\s\S]+?)%>/g
};

// JavaScript micro-templating, similar to John Resig's implementation.
// Underscore templating handles arbitrary delimiters, preserves whitespace,
// and correctly escapes quotes within interpolated code.
_.template = function(str, data) {
var c = _.templateSettings;
var tmpl = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +
'with(obj||{}){__p.push(\'' +
str.replace(/\\/g, '\\\\')
.replace(/'/g, "\\'")
.replace(c.escape, function(match, code) {
return "',_.escape(" + code.replace(/\\'/g, "'") + "),'";
})
.replace(c.interpolate, function(match, code) {
return "'," + code.replace(/\\'/g, "'") + ",'";
})
.replace(c.evaluate || null, function(match, code) {
return "');" + code.replace(/\\'/g, "'")
.replace(/[\r\n\t]/g, ' ') + "__p.push('";
})
.replace(/\r/g, '\\r')
.replace(/\n/g, '\\n')
.replace(/\t/g, '\\t')
+ "');}return __p.join('');";
var func = new Function('obj', tmpl);
return data ? func(data) : func;
};
就这么点,完了~ hoho~
lijia18
2011 年 11 月 10 日
jinja2 +1
jckwei
2011 年 11 月 13 日
我是来投 tenjin 的
clino
2011 年 11 月 15 日
我也推荐 uliweb ,是能在 html 里面内嵌 python 代码的
lerry
2012 年 2 月 14 日
jinja2
shawiz
2012 年 2 月 14 日
@yuest 怎样的前后端共用?是不是 js + python?
yuest
2012 年 2 月 15 日
@shawiz 恩,当时就用两个版本的 mustache。
不过对于 js 来说,mustache 是个性能很差的模板引擎
jo32
2012 年 2 月 15 日
选择真多,我觉得选社区资源多的就好了。。。
cloudream
2012 年 2 月 15 日
@chuangbo jQuery template plugin是这么回事儿:

微软VS团队引入jQuery时写了这个东西(当时jQuery项目一个新闻是MS和NOKIA开发工具原生支持jQuery)。

现在发布的jQuery template plugin是:John Resig看了一遍微软写的,当着微软员工的面,cmd+A,delete,然后现场重写了一遍⋯⋯
onlytiancai
2012 年 2 月 15 日
哈哈,楼上说的是真事吗
whtsky
2012 年 2 月 15 日
tenjin+1…
kojp
2012 年 2 月 15 日
看完所有回复 ,好迷茫 ..
不是以前一直听 livid说 tornado很不错的吗 ?
我还是先把 django学好再说吧 ..
shawiz
2012 年 2 月 16 日
andy
2012 年 2 月 16 日
@cloudream 这太伤人了,M$员工都有强烈的优越感。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://study.congcong.us/t/700

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX