Ahmed Abbas
Ahmed Abbas

Reputation: 962

How do you add dynamic partial by concatenating strings in ember js?

We can add partials onto templates in ember js.

{{#each subdetail in leftSubDetails}}
   {{partial 'lists/details/link-'+subdetail}}
{{/each}}

Gives following error

Error: Parse error on line 22:
...lists/details/link-'+subdetail}}
-----------------------^
Expecting 'CLOSE', 'CLOSE_UNESCAPED', 'STRING', 'INTEGER', 'BOOLEAN', 'OPEN_SEXPR', 'CLOSE_SEXPR', 'ID', 'DATA', got 'INVALID'

Upvotes: 0

Views: 293

Answers (2)

user663031
user663031

Reputation:

Compute the name of the partial as in the view or controller:

partialName: function() {
    return 'lists/details/link/ + this.get('subdetail');
}.property('subdetail')

Then call it like

{{partial partialName}}

Not tested.

Upvotes: 3

Kiffin
Kiffin

Reputation: 1037

Try passing a parameter instead, like this:

{{partial 'lists/details/link' subdetail=blah}}

Upvotes: 0

Related Questions