Rahul_Dabhi
Rahul_Dabhi

Reputation: 730

How to render multiple templates using #each in a handlebars?

I have one array of objects inside this objects I have some list of id's and using this id's I have to render multiple templates using #each loop for handlebars.

Simple this statement will return me the list of containing names of template.

{{#each data in sections1}}
{{data.id}}
{{/each}}

Output :

A B C D E F G H I J K L M N O P Q R S T U V W X

Consider this all A to Z are different template names respectively Now I'm trying to render all these templates using #each loop in handlebar But I don't know the exact syntax.

For example can we do like this way ?

{{#each data in sections1}}
{{render data.id}} //Here I'm getting error Because of it is not exact syntax
{{/each}}

Upvotes: 1

Views: 856

Answers (1)

Akis
Akis

Reputation: 2313

Maybe you should consider using partials, naming them with the proper name based on data.id value. Then use them like: {{partial data.id}}

DEMO

Upvotes: 1

Related Questions