Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember CLI can't find partial

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?

like image 733
user3568719 Avatar asked Apr 02 '15 16:04

user3568719


2 Answers

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'}}
like image 73
GJK Avatar answered Oct 23 '22 00:10

GJK


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.

like image 25
pzuraq Avatar answered Oct 22 '22 22:10

pzuraq