mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
Merge pull request #229 from stedman/patch-1
docs: Add hashes to `for` tag documentation
This commit is contained in:
+18
-1
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user