AkshayP
AkshayP

Reputation: 2169

how to break {{#each}} in emberjs handlebars

I want to know how to break or continue {{#each}} loop in emberjs handlebars.

 <ul>
   {{#each people}}
     //if name == 'xyz' i want to break the loop
     // else list the name
     <li>{{name}}</li>
   {{/each}}
 </ul>

I know how to use conditions, like below

   {{#if (eq name "xyz")}}
        bye
    {{else}}
        {{name}}
    {{/if}}

Upvotes: 3

Views: 2744

Answers (1)

Ember Freak
Ember Freak

Reputation: 12872

There is no break or continue in emberjs handlebars for each block. so I would encourage you to modify the people array through computed property.

peopleLimited:Ember.comptued('people.[]',function(){
 let result = [];
 //implement your logic here to cut down people array.
 return result;
});

Upvotes: 3

Related Questions