handlebars-lang / handlebars-lang/handlebars.js
Don't change the current context if using `#each ... as |...|`
- Dominant language
- JavaScript
- Stars
- 18.7k
- Forks
- 2.1k
- PR merge metrics
- No merged PRs in 30d
Description
It does not make sense at all that a snippet like this:
```hbs
{{someVal}}
{{#each profiles as |profile|}}
{{profile.username}}
{{someVal}}
{{/each}}
```
changes the current context, instead of just assigning the new context (the current element of `profiles`) to a new identifier (profile).
`{{someVal}}` should be accessible inside and outside the `{{#each}}` block, instead of forcing us to do this:
```hbs
{{someVal}}
{{#each profiles as |profile|}}
{{profile.username}}
{{@root.someVal}}
{{/each}}
```
If `profiles` already exits in the current context, it should be overwritten.
Contributor guide
Research direction
The issue does not name a file or test. Reproduce the two provided Handlebars snippets, then locate the implementation and tests for #each block context and named aliases; done means someVal resolves inside and outside the block while profile remains available as the current element.
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
- 45/100