More Array Conditionals in Templates

Feature Requests
  • These two conditions would be particularly useful:

    • True if the current iteration is the n-th interation (rather than just @first and @last)
    • True every n iterations, for example:

    1st iteration: false
    2nd iteration: false
    3rd iteration: true
    4th iteration: false
    5th iteration: false
    6th iteration: true
    7th iteration: false
    etc. etc.

  • I'm not too sure if we should be adding too much logic in the templates (gets super messy). That said, there is a way for you to accomplish the above, via helpers.

    JS:

    templates.registerHelper('iterateFn', function(data, iterator, total) {
        return (data.someVar && iterator === 3) ? true : false;
    });
    

    Templates:

    <!-- BEGIN someLoop -->
    {function.iterateFn}
    <!-- END someLoop -->
    

    Some real-world examples found here (none using the iterator variable as of yet though)


Suggested Topics