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

后端 未结 8 1462
旧巷少年郎
旧巷少年郎 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:49

    As of 2.0.0 partials now supports passing in values.

    {{#each items}}
        {{> item-template some_parent_var=../some_parent_var}}
    {{/each}}
    

    Took me awhile to find this, hope it's useful for someone else too!

提交回复
热议问题