Last active
December 19, 2015 08:29
-
-
Save Wolfr/5926144 to your computer and use it in GitHub Desktop.
How to get sub items from an array in Liquid?
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
| JSON: | |
| case studies: [ | |
| [ "Nubaru", | |
| ["Nubaru Yearly Report", "Web design", "2013", "/case-studies/Nubaru.html", "/images/case-studies/Nubaru.png"] | |
| ], | |
| [ "Ekande", | |
| ["Ekande application", "Web application design", "2013", "/case-studies/Ekande.html", "/images/case-studies/Ekande.png"] | |
| ] | |
| ] | |
| Jekyll HTML: | |
| <ul> | |
| {% for items in page.case-studies %} | |
| {% for item in items %} | |
| <li> | |
| {{ item }} | |
| <!-- How to get sub items? --> | |
| </li> | |
| {% endfor %} | |
| {% endfor %} | |
| </ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can access sub-items as you would in a programming language: via square brackets and array indices:
However, for your use-case it might be more maintanable for each case study to be a hash; then you would iterate an array of hashes. See my fork. I've used YAML syntax but it should allow you to some degree to paste in JSON as well.