【发布时间】:2012-05-15 09:06:44
【问题描述】:
为了与 asp.net webforms 兼容,我不得不替换默认的下划线 teplating delimiters/Interpolate regex。从网站上我选择了类似 mustache 的语法
_.templateSettings = {
interpolate : /\{\{(.+?)\}\}/g
};
试过了
_.template("{{if(loggedIn)Welcome {{name}}}}",{name:"James",completed:true});
但这似乎不是使用模板系统检查布尔表达式的方式(因为发生错误)。但从文档看来这是可能的
以及执行任意 JavaScript 代码,使用
- 那么我如何使用上面提到的插值执行任意js代码
【问题讨论】:
标签: javascript templates underscore.js boolean-logic underscore.js-templating