for
Repeats a block for each item.
Inside the loop, forloop gives the position. limit and offset take part of the array, reversed walks it backwards, and else renders when the array is empty. Loops stop after 10,000 iterations per render.
Syntax
Section titled “Syntax”{% for item in array limit: 4 offset: 0 reversed %}…{% else %}…{% endfor %}Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
limit |
number | Most items to loop over. |
offset |
number | Items to skip first. |
reversed |
flag | Loop from the end. |
Examples
Section titled “Examples”{% for variant in product.variants %}{{ forloop.index }}. {{ variant.title }}{% unless forloop.last %}, {% endunless %}{% endfor %}1. S / Sand, 2. M / Sand, 3. L / SandRanges and else
Section titled “Ranges and else”{% for i in (1..3) %}{{ i }}{% endfor %} {% for item in cart.discounts %}{{ item }}{% else %}No discounts{% endfor %}123Related
Section titled “Related”Compatibility
Section titled “Compatibility”Shopify: Same as Shopify.
Since theme platform 1.0.
Was this page helpful?

