【发布时间】:2016-01-06 12:07:04
【问题描述】:
我尝试使用 question 使用 require 函数全局覆盖模板函数,它适用于 templateSetting。
我尝试使用以下代码扩展/覆盖_.template 函数以包装 div。但是使用普通模板而不是像这样 <%= title %>
define(['underscoreBase'], function(_) {
_.template = function(str){
return "<div class='test'>"+str+"</div>";
};
return _;
});
我们如何使用 _.template 字符串内容添加/包装一些 HTML 标记?请指教。
【问题讨论】:
-
扩展和覆盖是完全不同的事情。你到底需要什么?
-
@HenriqueBarcelos 我想覆盖 _.template 字符串以用 HTML 包装
标签: javascript html underscore.js lodash underscore.js-templating