Last active
February 25, 2017 22:32
-
-
Save DanRader/5854822cbb4bd756f642e9024190a088 to your computer and use it in GitHub Desktop.
Alternating Rows using forloop.index and modulo
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 posts in site.posts %} | |
| {% assign loopindex = forloop.index | modulo: 6 %} | |
| {% if loopindex == 1 %} | |
| <div> {{ forloop.index }} | |
| {% elsif loopindex == 2 %} | |
| {{ forloop.index }} | |
| {% elsif loopindex == 3 %} | |
| {{ forloop.index }} </div> | |
| {% elsif loopindex == 4 %} | |
| <div class="foo"> {{ forloop.index }} | |
| {% elsif loopindex == 5 %} | |
| {{ forloop.index }} | |
| {% elsif loopindex == 0 %} | |
| {{ forloop.index }} </div> | |
| {% endif %} | |
| {% if forloop.last == true %} | |
| </div> | |
| {% endif %} | |
| {% endfor %} |
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
| <div class="container blog-list-wrapper"> | |
| {% for post in site.posts %} | |
| {% assign loopindex = forloop.index | modulo: 6 %} | |
| {% if loopindex == 1 %} | |
| <div class="row blog-list"> {% include blog/list-item.html %} | |
| {% elsif loopindex == 2 %} | |
| {% include blog/list-item.html %} | |
| {% elsif loopindex == 3 %} | |
| {% include blog/list-item.html %} </div> | |
| {% elsif loopindex == 4 %} | |
| <div class="row blog-list push"> {% include blog/list-item.html %} | |
| {% elsif loopindex == 5 %} | |
| {% include blog/list-item.html %} | |
| {% elsif loopindex == 0 %} | |
| {% include blog/list-item.html %} </div> | |
| {% endif %} | |
| {% if forloop.last == true %} | |
| </div> | |
| {% endif %} | |
| {% endfor %} | |
| </div> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Playing with numbers only —output of alternatingrows.html

high-fi Results
