-
-
Save keyurshah/651f6f411c43faf2d99843e3d7d701db to your computer and use it in GitHub Desktop.
[Collection loop] Check odd/even
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% for product in collection.products %} | |
{% comment %} | |
{% capture remainder %}{{forloop.index | modulo: 2}}{% endcapture %} | |
{% if remainder == '0' %} | |
{% assign is_even = true %} | |
{% else %} | |
{% assign is_even = false %} | |
{% endif %} | |
{% if is_even == false %}<ul class="product-grid clearfix">{% endif %} | |
<li{% cycle '', ' class="last-in-row"' %}> | |
{% include 'product-grid-item' %} | |
</li> | |
{% if is_even %}</ul>{% endif %} | |
{% endcomment %} | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment