group-helper
group-helper copied to clipboard
#group & #with not working together.
I noticed issues concerning use of {{#group}} & {{#with}} in EmberJS 1.0 & 1.3:
Consider template file element.handlebars:
{{#group}}
{{#each item in items}}
{{#with item}}
{{#if item.containedInParent}}
{{#unless item.showWithControls}}
<li>
{{partial 'element'}}
</li>
{{/unless}}
{{/if}}
{{/with}}
{{/each}}
{{/group}}
This seems to work with only a single level of recursion, i.e. nested {{#each}} never get rendered.
On the other hand the following:
{{#each item in items}}
{{#group}}
{{#with item}}
{{#if item.containedInParent}}
{{#unless item.showWithControls}}
<li>
{{partial 'element'}}
</li>
{{/unless}}
{{/if}}
{{/with}}
{{/group}}
{{/each}}
seems to generate infinite recursion (tested in Chrome & Firefox).
Besides group-helper, is there any other place in EmberJS that sets insideGroup to true? Is the code path where insideGroup is true tested in any way in EmberJS?
I should probably add: when I remove {{#group}}, everything works fine, the tree structure is rendered as it should.
do you mind throwing down a jsbin or jsfiddle?
Here's a jsfiddle demonstrating the problem:
Compare: http://jsfiddle.net/CbmmM/2/ and http://jsfiddle.net/CbmmM/4/
Once {{#group}} block is added, I get an exception undefined is not a function somewhere inside the {{#with}} tag.
Actually, it seems it doesn't work even when no {{#with}} block is used. Basically, the variable bound by the loop becomes inaccessible. Doesn't cause an exception though.
The {{#each}} tag however still iterates over the values.
Any chance of having this corrected? I would be willing to contribute a patch if I had a clue how the feature works.
@julkiewicz thanks for reporting this, someone will take a look as they have time.
Experiencing the same issue.
Also seems to happen if you assign the current item a different name in an each block (e.g. {{#each person in people}} {{/each}})