5

I am working on an addon. I try to use partial. In my addon/templates/components/form.hbs I got {{partial "pane"}}. My _pane.hbs is in addon/templates folder but ember can't find it:

Uncaught Error: Assertion Failed: Unable to find partial with name "pane".

I also tried to put _pane.hbs in addon/templates/components but no luck. Where should I put it to get picked up by ember?

Puck
  • 2,080
  • 4
  • 19
  • 30
user3568719
  • 1,036
  • 15
  • 33

3 Answers3

7

As mentioned here, everything is dasherized in Ember CLI. Use a dash instead of an underscore.

Also, I think the partial helper resolves starting in the templates directory. If you want to store a partial in the components directory, you'll probably have to make that explicit.

So your file should be named:

addon/templates/components/-pane.hbs

And your call should look like:

{{partial 'components/pane'}}
h0lyalg0rithm
  • 150
  • 1
  • 6
GJK
  • 37,023
  • 8
  • 55
  • 74
  • For future readers... "the partial helper resolves starting in the templates directory" this is key, the helper doesn't drill down from where it is, so you have to assume it's 'root' is the template folder when writing the path. – sheriffderek Aug 23 '15 at 16:17
2

Templates under addon/templates do not get included in the standard Ember build chain, and aren't found by the standard Ember resolver. This is why you have to manually import templates and assign them to as the layout in your component.

If you want to use a partial in your addon you will have to place it under app/templates. This is unadvisable however as not only will the partial not be precompiled with your addons templates, it will pollute the root application's template namespace.

This will probably be addressed by upcoming versions of ember-cli, addons are going to be changing significantly soon.

pzuraq
  • 619
  • 5
  • 13
0

If you want an application to access things in your addons then they need to be in the app directory not the addon directory. The app directory of each addon gets merged with the users app directory.

Usually all your logic lives in the addon directory and you simply import then export each item in the app directory (the app directory is therefor very dumb and simply contains a list of exports)... With templates however I'm not sure how that would be possible?

You could try addon/templates/_partial.hbs then import it in app/templates/_partial.js but again I'm not sure if that would work or not.. If that doesn't work see if putting it in app/templates/_partial.hbs works

jmurphyau
  • 2,309
  • 13
  • 11