How to include other files in ember-cli?


#1

Say I have a helper file which looks like:

Sonatribe.helpers = {
    doSomething: function(){
        //blah
    }
};

this file lives in a folder next to my routes, controllers, models etc

How do I include my helpers in my cli app?


#2

I would generally place the file at app/helpers/do-something.js:

export default function() {
  // blah
}

Then imported it wherever needed:

import doSomething from '../helpers/do-something';

#3

Ahhh I thought helpers were a template helper thing… not sure where I got that from!


#4

I actually managed to get this working by adding it to my vendors folder and telling broccoli where it was :smile:

As a side - but related - I want to add lo-dash to my app. I have added it via bower remembering to --save

I have added the following to my brocfile:

app.import('bower_components/lodash/dist/lodash.js');

but it doesn’t seem to take - is there anything else I need to do?