After updating Ember-CLI on my project from 0.2.0 to 0.2.3 I find myself to be unable to import any helper-generated functions to any other file.
I created a new project to test it, here's how I tried.
ember -v
version: 0.2.3
Could not find watchman, falling back to NodeWatcher for file system events.
Visit http://ift.tt/1OvndU1 for more info.
node: 0.12.2
npm: 2.7.6
- Created a new app with:
ember new my-app -
After the app was created, I created a new helper with
ember g helper test-helperand made its function only return the texttest, like so:import Ember from 'ember'; export function testHelper(params/*, hash*/) { return 'test'; }export default Ember.HTMLBars.makeBoundHelper(testHelper);
-
Edited the
app/templates/application.hbsto call the newtest-helperlike so:<h2 id="title">Welcome to Ember.js</h2> {{test-helper}}
Up to this point, everything works well, the text "test" shows up under the header on the index page when running ember server and visiting the correct URL.
- Create a controller for application using
ember g controller application -
Import the helper's function to this new controller and set a computed property on it by calling that controller like this:
import Ember from 'ember'; import testHelper from 'my-app/helpers/test-helper.js'; export default Ember.Controller.extend({ helperText: function () { return testHelper(); }.property() }); - Made
app/templates/application.hbsdisplay the new property by placing{{helperText}}inside it - Ran
ember server, it did not complain in any way other than having an unused variable params. -
Visit Ember's URL, I receive this error:
Error while processing route: index Could not find module `my-app/helpers/test-helper.js` imported from `my-app/controllers/application` Error: Could not find module `my-app/helpers/test-helper.js` imported from `my-app/controllers/application`
I've also tried using a single-word helper (simply test), but that changed nothing. I created a new project just to confirm this is either a bug or something I am doing incorrectly and not an issue with my current project.
The unchanged code from my project worked in the 0.2.0 version of ember-cli but simply downgrading it using npm seems to trigger another error (and I wish to keep ember-cli updated anyway).
I've tried Googling but found no similar results.
So, is there any way to include a helper's function like I could in the past or has this behaviour been replaced with something else? Am I doing something wrong, and if so, what?
Thanks.
Aucun commentaire:
Enregistrer un commentaire