3
votes

I am playing around with Ember.js (within Rails app) and got the the point when displaying a form. I used "partial" handlebars tag, like this:

{{partial "entity_edit_fields"}}

Ember tries to retrieve the template from _entity_edit_fields.hbs file. However, I have put all templates related to entity into separate directory. Now, I'd like to tell Ember to look to entity/_edit_fields.hbs. How can I achieve this?

1

1 Answers

10
votes

To include the template entity/_edit_fields.hbs as a partial use:

{{partial "entity/edit_fields"}}

If you get stuck on something like this again, try having a look at the ember test suite. There will almost always be an example there that can help answer your question. I wasn't sure how partial worked either, so before answering I had a look at 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.");
});