为了与 asp.net webforms 兼容,我不得不替换默认的下划线 teplating delimiters/Interpolate regex。从网站上我选择了类似 mustache 的语法
_.templateSettings = {
interpolate : /\{\{(.+?)\}\}/g
};
试过这个
_.template("{{if(loggedIn)Welcome {{name}}}}",{name:"James",completed:true});
但似乎这不是使用模板系统检查布尔表达式的方式(因为发生错误)。但从文档看来这是可能的
以及执行任意 JavaScript 代码,使用 <% ... %>
- 那么我如何使用上述插值执行任意js代码