Created
May 10, 2017 14:38
-
-
Save joe-dempsey/b9eabf6883647f5b75ad027fc9d461f3 to your computer and use it in GitHub Desktop.
using modulo in liquid to case odd even in a loop
This file contains 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
{% comment %} | |
Here we loop through a blog and use modulo to case odd/even. | |
Dead simple. | |
{% endcomment %} | |
{% for article in blog.articles %} | |
{% assign mod = forloop.index | modulo: 2 %} | |
{% if mod == 0 %} | |
<!-- it's even so do something...--> | |
{% else %} | |
<!-- it's odd so do something else... --> | |
{% endif %} | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to this modulo usage, originally I can't take integer, with this example, I can take integer, for Jekyll post timeline production