From acdd121a610852f9283e029e55c9849b07f3e15d Mon Sep 17 00:00:00 2001 From: Steve Stedman Date: Thu, 21 May 2020 10:56:57 -0500 Subject: [PATCH] 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 --- docs/source/tags/for.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/source/tags/for.md b/docs/source/tags/for.md index 08fb6a719..26eae804f 100644 --- a/docs/source/tags/for.md +++ b/docs/source/tags/for.md @@ -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.