Ember: How do I find matching parts in the catalog?

I am playing around with Ember.js (in a Rails app) and got the hang of it when rendering a form. I used a "partial" handlebars tag, for example:

{{partial "entity_edit_fields"}}

      

Ember is trying to extract the template from the _entity_edit_fields.hbs

file. However, I put all the templates associated with the object in a separate directory. Now I want to tell Amber to look at entity/_edit_fields.hbs

. How can I achieve this?

+3


source to share


1 answer


To include a template entity/_edit_fields.hbs

as a partial use:

{{partial "entity/edit_fields"}}

      



If you're stuck with something similar again, try taking a look at the ember test suite. There will almost always be an example that can help answer your question. I wasn't sure how partially it works, so before answering I looked 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.");
});

      

+10


source







All Articles