ghosh
ghosh

Reputation: 163

How to add dynamic value in handlebar partial path

In my file I have a call to an external handlebars partial like this

{{> docs/setup/install }}

This works fine. 'install' is the name of the partial.

I want to dynamically call other files using the partial helper. Something like this

{{> docs/setup/{{filename}} }}

This obviously is not working. It is an example of what I am trying to achieve.

How do I pass the dynamic {{filename}} to the include partial helper?

I am on node and using the express-hbs library.

Upvotes: 2

Views: 3014

Answers (1)

dhruvpatel
dhruvpatel

Reputation: 1269

You may want to use "subexpressions".

Refer to the documentation available here : https://handlebarsjs.com/guide/partials.html#dynamic-partials

Upvotes: 2

Related Questions