group-helper icon indicating copy to clipboard operation
group-helper copied to clipboard

#group & #with not working together.

Open julkiewicz opened this issue 11 years ago • 9 comments

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?

julkiewicz avatar Jan 11 '14 02:01 julkiewicz

I should probably add: when I remove {{#group}}, everything works fine, the tree structure is rendered as it should.

julkiewicz avatar Jan 11 '14 02:01 julkiewicz

do you mind throwing down a jsbin or jsfiddle?

stefanpenner avatar Jan 11 '14 03:01 stefanpenner

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.

julkiewicz avatar Jan 11 '14 17:01 julkiewicz

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.

julkiewicz avatar Jan 11 '14 17:01 julkiewicz

The {{#each}} tag however still iterates over the values.

julkiewicz avatar Jan 11 '14 18:01 julkiewicz

Any chance of having this corrected? I would be willing to contribute a patch if I had a clue how the feature works.

julkiewicz avatar Jan 12 '14 21:01 julkiewicz

@julkiewicz thanks for reporting this, someone will take a look as they have time.

stefanpenner avatar Jan 12 '14 22:01 stefanpenner

Experiencing the same issue.

jockee avatar Mar 07 '14 19:03 jockee

Also seems to happen if you assign the current item a different name in an each block (e.g. {{#each person in people}} {{/each}})

zackangelo avatar Mar 19 '14 17:03 zackangelo