for
Renders an expression for each item in an array.
You can use a for loop for up to 50 iterations. If you need to iterate over more than 50 items, use the paginate helper to split the items into multiple pages.
Tip
Each for loop has an associated forloop object that contains information about the loop.
Parameters
list- The list to iterate over.hash.limit- Limits the number of iterations.hash.offset- Specifies the starting element for iteration (1-based index).hash.reversed- Use the reversed parameter to iterate in reverse order.
Usage
{{#for array as |item|}}
expression
{{else}}
empty
{{/for}}
Examples
{{#for collection.products as |product|}}
{{product.title}}
{{else}}
There are no products in this collection.
{{/for}}
limit
{{#for collection.products limit=2 as |product|}}
{{product.title}}
{{/for}}
offset
{{#for collection.products offset=2 as |product|}}
{{product.title}}
{{/for}}
reversed
{{#for collection.products reversed=true as |product|}}
{{product.title}}
{{/for}}
Was this article helpful to you?