vendredi 1 avril 2016

Meteor template each loop, provide other template each X results

Is it possible to insert specific data when meteor parse a collection with {{#each}} template logic only each X collection entry?

Exemple:

HTML
    {{#each collection}}
                 <div>
                    <p>{{collectionparam1}} - {{collectionparam2}}</p>
                    {{#if **collection[only multiple of 2]**}}
                       <p>I show this {{collectionparam3}} only each 2 entries</p>
                    {{/if}}
                 </div>      
    {{/each}}

Results:

Billy - 24
Joe - 12
I show this banana only each 2 entries
Bob - 88
Maria - 5
I show this cherry only each 2 entries
Samantha - 102
Henry - 43
I show this apple only each 2 entries

If possible, what do I have to put on {{#if}} logic?

Thanks for your help.

Aucun commentaire:

Enregistrer un commentaire