我正在尝试从templates/about.handlebars
呈现模板。
我在rails视图中设置了插座:
%script{ type: 'text/x-handlebars'}
<h1> My app</h1>
{{ outlet }}
^-- outlet
about路线看起来像这样:
Admin.Router.map ->
@route 'about', path: '/'
关于模板是简单的html:
<h1>This is ABOUT!</h1>
似乎有效:
但是,当我要求Ember.TEMPLATES
时,我得到:
Object {application: function}
application: function (context, options) {
__proto__: Object
并且没有关于那里的模板。
在已编译的js文件中挖掘,我可以看到车把模板在物理上存在:
(function() {
this.HandlebarsTemplates || (this.HandlebarsTemplates = {});
this.HandlebarsTemplates["about"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
return "\n<h1>This is ABOUT!</h1>\n\n";
});
return this.HandlebarsTemplates["about"];
}).call(this);
但我没有看到它被明确添加到Ember.TEMPLATES。
更新1:检查ember-rails gem,我看到了把手will match only files that have .raw.(hjs|...)
, or mustache.(hjs|...)
in their names?文档似乎没有谈到这一点。
即使我重命名模板,它仍然没有显示,它的晚餐很奇怪,因为我没有在教程或gem文档中看到类似的模板名称。
答案 0 :(得分:0)
Ember在Ember.TEMPLATES中查找预编译的模板,而不是HandlebarsTemplates。