Skip to content

Instantly share code, notes, and snippets.

@thisislawatts
Last active August 29, 2015 14:24
Show Gist options
  • Save thisislawatts/0be5d3d424e874c81e8c to your computer and use it in GitHub Desktop.
Save thisislawatts/0be5d3d424e874c81e8c to your computer and use it in GitHub Desktop.
Liquid Counter Loop
{% comment %}
I only want to echo out `Do something` six times on this page
But `something_we_cant_limit might` could contain 22 items or 2
{% endcomment %}
{% assign counter = 'i' %}
{% for item in something_we_cant_limit %}
{% capture counter %}{{ counter }}i{% endcounter %}
{% if capture.size < 6 %}
Do something
{% endif %}
{% endfor %}
{% for item in something_unrelated_you_cant_limit %}
{% capture counter %}{{ counter }}i{% endcounter %}
{% if capture.size < 6 %}
Do something
{% endif %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment