mistahenry
mistahenry

Reputation: 8724

Naming Ember.js files whatever I want

I used the Ember CLI to generate the project structure for my app. Specifically, I used ember generate resource account The structure is (ignoring parts that aren't pertinent):

app
    components
    controllers
    models
        account.js
    routes
        account.js
    templates

In Intellij, when I look at the tabs of open files, I see two different files named account.js. I then have to guess which file is the model or the route depending on what I want (picking the wrong one half of the time). I have a bunch more files than the ones that I mentioned here, all with same duplication problem. Is there a way I rename the account file to say account-model.js and have it all still wire up in ember? Could be a broccoli.js specific question since that's the default Ember-CLI build tool

In the same vein, I also want to be able to nest my templates into different folders based on my nested resources and routes. I'm having a hard time figuring out how to render these templates once I've changed the directory structure

Upvotes: 4

Views: 400

Answers (1)

nightire
nightire

Reputation: 1371

For templates, as @torazaburo said, you can split the long file name to path/to/template form.

For Naming Conventions, yes, you can change the default naming convention by define your own Resolver, check Ember.DefaultResolver API document for details. It's not so hard.

And you can also change the IntelliJ settings for tabs, let it show the full path than just filename(only when same name appears), this is much easier than define a custom resolver. You can check this setting at:

Preference -> IDE Settings -> Editor -> Editor.Tabs -> Show directory in editor tabs for non-unique file names

Upvotes: 3

Related Questions