CamelCase vs snake_case vs dash-s in Ember.js application

I could not find clear directions on where to use CamelCase vs snake_case vs dash-s in different parts of the Ember.js application.

Which of the following cases is recommended and what impact can I have if I replace one with another?

this.route('favoriteAuthor')
this.route('favorite_author')
this.route('favorite-author')

this.modelFor('favoriteAuthor')
this.modelFor('favorite_author')
this.modelFor('favorite-author')

this.get('store').find('favoriteAuthor')
this.get('store').find('favorite_author')
this.get('store').find('favorite-author')

{{render 'favoriteAuthor'}}
{{render 'favorite_author'}}
{{render 'favorite-author'}}

this.controllerFor('favoriteAuthor')
this.controllerFor('favorite_author')
this.controllerFor('favorite-author')

this.transitionTo('favoriteAuthor')
this.transitionTo('favorite_author')
this.transitionTo('favorite-author')

Thanks,

+4
source share
2 answers

camelCase-s are for model, controller, convection routing for javaScript. Dashes are for helper assistants (before they were also camelCase). snake_case is used for parameters like post_id ... photo_id, etc.

+2
source

, , ember . , snake_case , CamelCase. :

App.SampleTestRoute = Ember.Route.extend();

:

"sample_test"

, !

0

Source: https://habr.com/ru/post/1526661/


All Articles