When I run ember g component foo-bar in an Ember Addon project (let's say addon-project), it generates following:
// addon-project/addon/components/foo-bar.js
import Ember from 'ember';
import layout from '../templates/components/foo-bar';
export default Ember.Component.extend({
layout
}
// addon-project/addon/templates/components/foo-bar.hbs
{{yield}}
// addon-project/app/components/foo-bar.js
export { default } from 'addon-project/components/foo-bar';
I noticed that it does not generate addon-project/app/templates/components/foo-bar.js to export the component template but explicitly link the template using layout.
Why not generate addon-project/app/templates/components/foo-bar.js? Is there a reason for this behavior?
Also why is layout imported using relative path instead of absolute path (i.e. import layout from 'addon-project/templates/components/foo-bar?
First - which version of
ember-clido you use? Blueprints depends on versionFor me it do next
so it generate template as well
Next - it use related path for import layour to decrease number of places which depends on addon namespace ( which is defined inside
index.js- so if you change that namespace in future - you should update only files which explicit maped into application )Oh. It didn't generate template bridge cause in component used layout. It allow you extend component without defining template ( you can just extend original component, add/change logic and skip creation template for it ) If you'll use template instead of layout - you should define template ( or use the same layout explicit ) manually