docs: Add hashes to for tag documentation

This extremely helpful information was found at https://github.com/Shopify/liquid/wiki/Liquid-for-Designers#allowed-collection-types
This commit is contained in:
Steve Stedman
2020-05-21 11:11:01 -05:00
parent 2de853e814
commit acdd121a61
+18 -1
View File
@@ -8,7 +8,7 @@ Iteration tags run blocks of code repeatedly.
### for...in
Repeatedly executes a block of code. For a full list of attributes available within a `for` loop.
Repeatedly executes a block of code. For a full list of attributes available within a `for` loop, see [forloop](#forloop).
Input
```liquid
@@ -22,6 +22,23 @@ Output
hat shirt pants
```
For loops can iterate over arrays, hashes, and [ranges of integers](#range).
When iterating a hash, item[0] contains the key, and item[1] contains the value:
Input
```liquid
{% for item in hash %}
* {{ item[0] }}: {{ item[1] }}
{% endfor %}
```
Output
```text
* key1: value1
* key2: value2
```
### else
Specifies a fallback case for a `for` loop which will run if the loop has zero length.