handlebars.java
handlebars.java copied to clipboard
Unexpected behaviour when using {{#with}} and {{#each}}
I have an example of some unexpected behaviour when using {{#with}} and {{#each}}
Good example:
{{#each (array 'a' 'b' 'c')}}
{{this}}
{{/each}}
Renders:
a
b
c
Bad example:
{{#with (array 'a' 'b' 'c') as |x|}}
{{#each x}}
{{this}}
{{/each}}
{{/with}}
Prints:
[a, b, c]
[a, b, c]
[a, b, c]
Is this behaviour expected? I would expect the second example to behave the same as the first one
One possible fix could be to introduce a {{@value}} syntax when iterating:
{{#with (array 'a' 'b' 'c') as |x|}}
{{#each x}}
{{@value}}
{{/each}}
{{/with}}