handlebars-lang / handlebars-lang/handlebars.js

Context within partials with arguments is acting weird

Open
#1,931 1 comment 0 reactions 0 assignees View on GitHub
needs investigation
Dominant language
JavaScript
Stars
18.7k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

`{{#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

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the nested block and inline-partial example from the issue in handlebars.js, then trace how partial arguments resolve ../ versus parent. Done means the inline partial resolves block_helper1's attribute consistently with the parent. form and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.