Skip to content

Instantly share code, notes, and snippets.

@NathanPJF
Last active January 2, 2018 11:01
Show Gist options
  • Save NathanPJF/251d85aee0a917e12bba to your computer and use it in GitHub Desktop.
Save NathanPJF/251d85aee0a917e12bba to your computer and use it in GitHub Desktop.
[Collection loop] Check odd/even
{% 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