是否有办法汇编服务器上的“强调”模板,和使封闭汇编者与生成的代码合作?
主要问题是<代码>_template:
_.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.interpolate, function(match, code) {
return " ," + code.replace(/\ /g, " ") + ", ";
})
.replace(c.evaluate || null, function(match, code) {
return " );" + code.replace(/\ /g, " ")
.replace(/[
]/g, ) + "__p.push( ";
})
.replace(/
/g, \r )
.replace(/
/g, \n )
.replace(/ /g, \t )
+ " );}return __p.join( );";
var func = new Function( obj , tmpl);
return data ? func(data) : func;
};
生成 Java本,并附有说明。 两个明显的路线是:
- modify Underscore.js s
_.template
not to generate withs - coerce Closure into playing nice
第二种选择是否可行?