Ember-cli addon with template


#1

Hi! I’m trying to convert one of my EmberComponent components into addon and I have problem to get component’s template working. Component itself is renderet properly, but without template which is defined in separate file.

I’ve found those issues describing same problem: https://github.com/ember-cli/ember-cli/issues/1967 https://github.com/ember-cli/ember-cli/pull/1983

I placed template in addon/templates/components/name.hbs like here: https://github.com/mharris717/ember-cli-pagination/tree/master/addon

Any idea about what I’m doing wrong? Or is there any issue with addons with handlebars templates?


#2

Perhaps this issue is related: https://github.com/ember-cli/ember-cli/pull/2714#issuecomment-69433413


#3

I’m using ember-cli 0.1.5 this is new issue in 0.1.9, right? When I move template to tests/dummy/app component is render properly using this template.


#4

there is a repository: https://github.com/turboMaCk/ember-select-combo


#5

Templates are supposed to go into app/templates, not into addon/templates.

AFAIK code in addon lives in the addon’s own namespace, which is implemented using ES6 modules. Hence you to have to import the component in app/components. But Handlebars templates have no notion of being namespaced, since they are not ES6 modules.


#6

Thank you for explanation! So from what I understand I have to implement component logic in addon/components/name.js, than in app/componets/name.js include those components (using ES6 import) and put template in app/templates/components. Than logic for in browser testing in app comes in tests/dummy/app/ right?


#7

Hi, I’m using ember-cli@0.2.0 and the component blueprint for addons is creating a template in the addon directory as well as an import statement for the template as layout. Has something changed in regards to how addons should support components that have templates? I’m seeing the same issue as the OP but it seems partials can only be used in the component template if the partial is in the app directory. It seems odd that the blueprint suggests the template should live in addon but partials only work from app. What is the suggested layout for things like this now?


#8

For folks stumbling onto this post, a later discussion (and a couple of working solution examples) is here: