{"result":{"depiction_url":null,"edges":{"subject":{"objects":[{"created":"2026-09-09T13:48:30Z","object_id":{"id":2555,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_reference","title":"Reference","uri":"https:\/\/zotonic.com\/id\/2555"},"seq":1},{"created":"2026-09-09T13:48:30Z","object_id":{"id":2563,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_frontend_developer","title":"Frontend developer","uri":"https:\/\/zotonic.com\/id\/2563"},"seq":2},{"created":"2026-09-09T13:48:30Z","object_id":{"id":2620,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_template","title":"Template","uri":"https:\/\/zotonic.com\/id\/2620"},"seq":3},{"created":"2026-09-09T13:48:30Z","object_id":{"id":2641,"is_a":["categorization","keyword","keyword_task"],"name":"zotonic_topic_render","title":"Render","uri":"https:\/\/zotonic.com\/id\/2641"},"seq":4},{"created":"2026-09-09T13:48:30Z","object_id":{"id":2664,"is_a":["categorization","keyword","keyword_data_type"],"name":"zotonic_topic_collection","title":"Collection","uri":"https:\/\/zotonic.com\/id\/2664"},"seq":5}],"predicate":{"id":308,"is_a":["meta","predicate"],"name":"subject","title":{"_type":"trans","tr":{"en":"Keyword"}},"uri":"http:\/\/purl.org\/dc\/elements\/1.1\/subject"}}},"id":1363,"is_a":["text","documentation","reference","template_tag"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1363"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_template_tag_tag_for","page_url":{"en":"https:\/\/zotonic.com\/docs\/1363\/for","x-default":"https:\/\/zotonic.com\/docs\/1363\/for"},"preview_url":null,"resource":{"version":4045,"pivot_location_lat":null,"title":"for","is_authoritative":true,"body":"<p>Loop over multiple values in a list or search result.<\/p>\n<p><code>{% for %}<\/code> loops over a list of values. For example to loop over a list of colors:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">{% for color in [&quot;bleu&quot;, &quot;blanc&quot;, &quot;rouge&quot;] %}{{ color }}{% endfor %}\n<\/code><\/pre>\n<p>This will output “bleublancrouge”.<\/p>\n<p>Or to show the latest ten news article titles:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">{% for id in m.search[{latest cat=&quot;news&quot; pagelen=10}] %}\n  {{ m.rsc[id].title }}\n{% endfor %}\n<\/code><\/pre>\n<p>The argument list can also contain tuples or sublists, in that case you can assign all parts of the list items to different variables at once:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">{% for nr,color in [ [1,&quot;bleu&quot;], [2,&quot;blanc&quot;], [3,&quot;rouge&quot;] ] %}\n  {{ nr }}: {{ color }}\n{% endfor %}\n<\/code><\/pre>\n<p>This will output:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">1: bleu\n2: blanc\n3: rouge\n<\/code><\/pre>\n<p>The for loop sets a number of variables available in the loop:<\/p>\n<table class=\"table\"><thead><tr><th>Variable<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>forloop.counter<\/td><td>The current iteration of the loop (1-indexed)<\/td><\/tr><tr><td>forloop.counter0<\/td><td>The current iteration of the loop (0-indexed)<\/td><\/tr><tr><td>forloop.revcounter<\/td><td>The number of iterations from the end of the loop (1-indexed)<\/td><\/tr><tr><td>forloop.revcounter0<\/td><td>The number of iterations from the end of the loop (0-indexed)<\/td><\/tr><tr><td>forloop.first<\/td><td>True if this is the first time through the loop<\/td><\/tr><tr><td>forloop.last<\/td><td>True if this is the last time through the loop<\/td><\/tr><tr><td>forloop.parentloop<\/td><td>For nested loops, this is the loop “above” the current one<\/td><\/tr><\/tbody><\/table>\n<h2>For ... empty<\/h2>\n<p><code>{% for %}<\/code> can take an optional <code>{% empty %}<\/code> clause that will be displayed if the given list is empty.<\/p>\n<p>For example:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">{% for id in m.search[{latest cat=&quot;news&quot; pagelen=10}] %}\n  {{ m.rsc[id].title }}\n{% empty %}\n  Sorry, there is no news.\n{% endfor %}\n<\/code><\/pre>\n<p>This will output “Sorry, there is no news.” when the “latest” search did not find any pages within the category “news”.<\/p>","slug":"for","is_protected":false,"visible_for":0,"tz":"UTC","language":["en"],"doc_source_hash":"24e61266daf7b2e2df2b1336e5c0475ebef40ad1979ef4eaa9e6e2856b36daa5","is_featured":false,"content_group_id":{"id":2551,"is_a":["meta","content_group"],"name":"content_group_imported_docs","title":"Imported documentation","uri":"https:\/\/zotonic.com\/id\/content_group_imported_docs"},"category_id":{"id":324,"is_a":["meta","category"],"name":"template_tag","title":"Tags","uri":"https:\/\/test.zotonic.com\/id\/324"},"doc_source_path":"doc\/template-tags\/for.md","publication_start":"2023-06-24T08:18:00Z","github_url":"https:\/\/github.com\/zotonic\/zotonic\/blob\/master\/doc\/template-tags\/for.md","pivot_location_lng":null,"doc_source_kind":"template_tag","name":"doc_template_tag_tag_for","is_unfindable":false,"is_published":true,"pivot_geocode":null,"created":"2020-05-30T05:47:19Z","uri":null,"doc_status":"current","is_dependent":false,"publication_end":"9999-06-01T00:00:00Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"privacy":0,"doc_source_commit":"c34f80c7ab6700e5d77ac5730deaae0e4710e159\n","creator_id":{"id":336,"is_a":["person","robot"],"name":"gitbot","title":"Git","uri":"https:\/\/zotonic.com\/id\/336"},"modified":"2026-10-19T13:18:46Z","title_slug":"for"},"uri":"https:\/\/zotonic.com\/id\/1363","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1363"}},"status":"ok"}