framework icon indicating copy to clipboard operation
framework copied to clipboard

Adopt component template co-location

Open mtgraham opened this issue 6 years ago • 3 comments

https://github.com/emberjs/rfcs/blob/master/text/0481-component-templates-co-location.md

HBS files are needlessly far from the javascript files they're associated with. The templates directory has become somewhat of a "kitchen sink" folder where there's not much structure. We should move the templates for components in the way described in the above RFC.

  • [x] app
  • [ ] core
  • [ ] dashboards
  • [x] data
  • [x] directory
  • [x] notifications
  • [ ] reports
  • [x] search

mtgraham avatar Dec 13 '19 20:12 mtgraham

  • 🎉 components/my-component.{hbs,js}
  • ❤️ components/my-component/index.{hbs,js}

kevinhinterlong avatar Dec 13 '19 20:12 kevinhinterlong

Do the generators produce this: components/my-component.js and components/my-component.hbs

If so, that is my vote. Also, it makes it a little easier for file searching in your editor (via ctrl-p).

jkusa avatar Dec 16 '19 17:12 jkusa

Generators have several options

https://github.com/emberjs/rfcs/blob/master/text/0481-component-templates-co-location.md#generator

It should accept a --component-structure option.

When this option is set to flat (aliased as -fs), the component's JavaScript and template files will both be generated at the root of {app,addon}/components.

When this option is set to nested (aliased as -ns), a folder will be generated for the component in {app,addon}/components, and the component's JavaScript and template files will be generated as index.{js,hbs} inside the folder.

When this option is set to classic (aliased as -cs), the component's template file will be generated in {app,addon}/templates/components. For addons, when used with --component-class=@ember/component, this will also emit the layout property workaround.

When this option is set to pods (aliased as --pods), it will generate {app,addon}/components/$name/{component.js,template.hbs}.

mtgraham avatar Dec 17 '19 22:12 mtgraham