我正在玩Ember.js(在Rails应用程序中)并且在显示表单时得到了重点.我使用了"部分"手柄标签,如下所示:
{{partial "entity_edit_fields"}}
Run Code Online (Sandbox Code Playgroud)
Ember尝试从_entity_edit_fields.hbs文件中检索模板.但是,我已将与实体相关的所有模板放入单独的目录中.现在,我想告诉Ember entity/_edit_fields.hbs.我怎样才能做到这一点?
Mik*_*tti 10
要将模板包含entity/_edit_fields.hbs为部分用途:
{{partial "entity/edit_fields"}}
Run Code Online (Sandbox Code Playgroud)
如果你再次陷入这样的困境,试试看看ember测试套件.几乎总会有一个例子可以帮助回答你的问题.我不确定部分是否有效,所以在回答之前我看了一下handlebars_test.js
test("should render other slash-separated templates using the {{partial}} helper", function() {
Ember.TEMPLATES["child/_subTemplate"] = Ember.Handlebars.compile("sub-template");
view = Ember.View.create({
template: Ember.Handlebars.compile('This {{partial "child/subTemplate"}} is pretty great.')
});
Ember.run(function() {
view.appendTo('#qunit-fixture');
});
equal(Ember.$.trim(view.$().text()), "This sub-template is pretty great.");
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4052 次 |
| 最近记录: |