Skip to content

Instantly share code, notes, and snippets.

@christophergregory
Created December 12, 2012 16:49
Show Gist options
  • Save christophergregory/4269413 to your computer and use it in GitHub Desktop.
Save christophergregory/4269413 to your computer and use it in GitHub Desktop.
Shopify: Array loop divider
<div id="looper">
{% assign range = 5 %}
{% assign min = 0 %}
{% assign max = range %}
{% assign iter = 0 %}
{% assign arr = 'asdfasdf,asdfasf,aafa,asdfas,asass,asdsd,asdads,asdfasf,asdadss,aflkjlfakl,asldf,asldkfjasl,aslas,asldkfjasldkfjasdkf,lskl,asdlfjadslkf,asdfasfs,asdflkjasdl,asdlfkjaslf,asdfas,asdlfkjasdfl,asdfalda' | split: "," %}
{% for i in arr %}
{% assign iter = forloop.index %}
{% if forloop.index0 == min %}
<div class="test">
{% endif %}
{% if forloop.index > min and forloop.index <= max %}
{{ i }}
{% endif %}
{% if forloop.index == max %}
</div>
{% assign min = min | plus: range %}
{% assign max = max | plus: range %}
{% endif %}
{% endfor %}
{% unless iter == max %}
</div><!-- End -->
{% endunless %}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment