handlebars - is it possible to access parent context in a partial?

后端 未结 8 1452
旧巷少年郎
旧巷少年郎 2020-12-04 15:40

I\'ve got a handlebar template that loads a partial for a sub-element.

I would need to access a variable from the parent context in the calling template, from within

8条回答
  •  一整个雨季
    2020-12-04 15:57

    Just in case anyone stumbles across this question. This functionality exists now in Handlebars.

    Do this:

    {{#each items}} 
        {{! Will pass the current item in items to your partial }}
        {{> item-template this}} 
    {{/each}}
    

提交回复
热议问题