I wish to pass the parent templates context to a handlebars partial.
I register my partial in app.js with the following
Handlebars.registerPartial("lifestyles", Handlebars.templates['partials/product-lifestyles']());
I then render my partial inside my main template file like the following, passing in this as a second parameters of which I understand it should pass in the context of the parent
{>lifestyles this}}
I have a log helper which console logs a parameter, inside my partial I log out this, it returns undefined.
{{log this}}
Evidentially my context isn't being passed into my partial.
My understanding is that Handlebars supports this functionality, so what could be the reason it is not functioning?
STHayden is right, You need two opening braces when you call a partial
{{>lifestyles this}}
This is an example of using partial templates
http://jsfiddle.net/UMBGC/16/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With