handlebars-lang / handlebars.js

Minimal templating on steroids.
http://handlebarsjs.com
MIT License
17.96k stars 2.04k forks source link

Context within partials with arguments is acting weird #1931

Open brdandu opened 1 year ago

brdandu commented 1 year ago

{{#block_helper1}} {{#block_helper2}} {{#if true}} {{#*inline "newInlineTest" argumentKey="argumentValue"}}{{../block_helper_1_attribute}}{{/inline}} {{>newInlineTest}} {{/if}} {{/block_helper2}} {{/block_helper2}}

For the above use case newInlineTest partial fetches the result from block_helper2 instead of block_helper1. However if I change the inline to {{#*inline "newInlineTest"}}{{parent.block_helper_1_attribute}}{{/inline}} then it fetches the result from block_helper1 like it is expected to. Seems like ../ and parent. are not behaving the same way for partials with arguments

bzbarsky-apple commented 1 year ago

And in particular, removing the {{#if true}} bit makes ../block_helper_1_attribute actually get a result from block_helper1. So the if is affecting scoping!