From 64b2baa567a4b322cc9d8b247546e736a730a35f Mon Sep 17 00:00:00 2001 From: Vlad Dumitrescu Date: Sun, 26 Aug 2018 20:32:59 +0200 Subject: [PATCH] [KB] Note about nesting collection loops syntax Feel free to improve wording. I don't know how to add a proper id via github, I hope it will be fine. --- content/collections/kb/nested-collections.md | 39 ++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 content/collections/kb/nested-collections.md diff --git a/content/collections/kb/nested-collections.md b/content/collections/kb/nested-collections.md new file mode 100644 index 00000000..9d7bcd0e --- /dev/null +++ b/content/collections/kb/nested-collections.md @@ -0,0 +1,39 @@ +--- +title: Nested collection loops +id: 889f5559-31d2-431a-9710-c09c58f0db51 +kb_categories: + - Tips, Tricks, and How-Tos +--- + +Sometimes one needs to nest collection loops, for example when implementing a master-detail page. + +The Antlers parser can't handle this form: +``` +{{ collection from="blog" }} +

+ {{ collection from="stuff" }} + {{ title }} + {{ /collection }} +

+{{ /collection }} +``` + +But this works : +``` +{{ collection:blog }} +

+ {{ collection from="stuff" }} + {{ title }} + {{ /collection }} +

+{{ /collection:blog }} +``` + +And so does this one: +``` +{{ collection from="blog|events" }} +

+ {{ partial:stuff_blog }} {{# contains the inner loop code #}} +

+{{ /collection }} +```