这是我的样例JST文件
(function() {
var _ref;
if ((_ref = window.JST) == null) {
window.JST = {};
}
window.JST['test'] = function(context) {
return (function() {
var $o;
$o = [];
$o.push("<h1>yayyyyyyaa</h1>");
return $o.join("\n");
}).call(context);
};
}).call(this);我在主干应用程序中使用require.js,比如
define ['backbone', 'marionette', 'text!javascripts/backbone/templates/test.jst'],
(Backbone, Marionette, template) ->
class Test extends Backbone.Marionette.ItemView
template: JST[template]当我加载这个应用程序时,我得到:
ReferenceError: JST is not defined为什么哦为什么!
谢谢!
发布于 2013-05-17 13:58:51
你的代码的问题是你在你的“模板”变量中得到了函数的文本。您仍然需要对该文本执行eval操作,以便在窗口上创建实际的JST实例。
作为一个整体,问题是你滥用了文本!plugin,你真正需要做的就是使用requireJs的模块,而不是把你的变量挂在窗口上。
https://stackoverflow.com/questions/16601778
复制相似问题