I have a Handlebar helper to invoke a template within a template,
the usage is this :
applyTemplate subTemplateId arg1=123 arg2="abc" ...
It is also possible to pass html content
{{# applyTemplate "tli" a=1 b="y"}}
... any content here will get passed to the sub template with {{content}}
{{/ applyTemplate }}
This jsFiddle illustrates how it works : http://jsfiddle.net/maxl/ywUjj/
My problem : I want the variables in the calling scope to be accessible in the sub templemplate, in the jsFiddle, notice how {{topLevelVar}} is not available.
Thanks
Starting from the solution on http://jsfiddle.net/dain/NRjUb/ we can achieve the same result but with inline templates as:
And registering the handlebars helpers like:
And calling this with:
Hope this helps :)
Add "../" before topLevelVar to access the parent context.
For example: {{../topLevelVar}}
From this example i would say you can use fn to access the context in your helper method http://yehudakatz.com/2010/09/09/announcing-handlebars-js/
Where fn is the inner "template" part, and context the model that gets applied to it.