I would like to know if it is possible to concat a variable with another string when loading a partial using Handlebars.
{{partial logos this ns=../ns nsr=../nsr id=id+"something"}}
I'd like to concat id+"something"
and storing it into id
, which would be sent to the template.
I'm using a custom helper to load partials (partial
) which merge this
with the options.hash
provided by handlebars.
If you're doing a simple
a + b
concatenation and you're already including handlebars-helpers, you can use theadd
helper:In ES6 this is possible using this helper:
concat : (...strs) => strs.join('')
You may also want to skip parameters given by Handlebars, which is:
concat : (...strs) => strs.filter( arg => typeof arg !== 'object' ).join('')
Try following. Link helper is my own helper for adding context path /us
Then I have called like this. My url having puppies
Then finally i got output like this /us/puppies
There is a way actually. I've tried with default partial loader ">", but I hope it should work with "partial" too.
You can write a helper like this
and Call it like
I hope that helps.
Here's an easier way. A helper named 'concat':
To be used as:
No, this is not possible. Use concatenation inside your helper.