【发布时间】:2015-02-05 09:55:44
【问题描述】:
我有一个事件需要在应用程序外部的空间中插入模板。使用 Ember-CLI,我们拥有所有这些出色的预编译模板,因此我正在尝试找出如何使用其中的一个。
(Ember-CLI 0.0.42,Ember 1.7.0)
我发现我可以像这样得到预编译的模板函数:
import TheTemplate from 'app/templates/the-template';
但是,如果我按照 Handlebars 网站上的说明调用它,则会收到错误消息。
var context = { button: "OK" };
var str = TheTemplate(context);
Uncaught TypeError: Cannot read property 'push' of undefined
那么使用这些模板的正确方法是什么?
【问题讨论】:
-
Handlebars.template("the-template") 也获取模板。
标签: ember.js handlebars.js ember-cli