samedi 4 avril 2015

Ember-cli addons and helpers

What is the correct way of placing your helper files and also where should they go with respect to the resolver finding them from an addon ember-cli project?


I am running ember-cli 0.2.2.


I generated an helper from an addon project with:



ember g helper display-helper


The generator placed the file in app/helpers which seemed wrong to me, I would have thought that it should have been placed in addon helpers. I moved the file to addon/helpers and it looks like this:



export default Ember.Handlebars.registerBoundHelper('displayHelper', function displayHelper(searchPath) {
return new Ember.Handlebars.SafeString(get(this, searchPath));
});


When I ran ember test I get the following output:



✘ Error: Assertion Failed: A helper named 'displayHelper' could not be found



The only way I get this helper to be found by the resolver is to add an import that references the helper in a component that is using it like this:



import displayHelper from '../helpers/display-helper';


This does not seem correct, I would have thought the resolver would have found this automatically?





Aucun commentaire:

Enregistrer un commentaire