0

我正在尝试测试主干应用程序。
当我需要测试一个简单的backbone.view 时,我没有问题。
如果我需要测试使用Backbone.Marionette(ItemView 或 CompositeView)制作的主干视图,Handlebars template我会收到以下消息:

NoTemplateError: Could not find template: 
function(context, options) {
    if (!compiled) {
      compiled = compile();
    }
    return compiled.call(this, context, options);
  };

关于的代码function(context, options)来自handlebars-1.0.0.beta.6.js.
知道如何修复代码吗?

这是我正在执行的测试:

describe("AppViewMarionette", function() {
    beforeEach(function(){
        this.view = new AppViewMarionette();

    });

    describe("Rendering", function () {

        it("returns the view object", function () {
            expect(this.view.render()).toEqual(this.view);
        });
    });

});
4

1 回答 1

3

您需要更新 Marionette 的版本。v0.9.1 不支持直接分配给template设置的预编译模板。为此,您需要 v0.9.7 或更高版本。

如果您无法更新,则需要按照以下说明进行操作:https ://github.com/derickbailey/backbone.marionette/wiki/Using-pre-compiled-templates

于 2012-08-14T19:13:13.153 回答