D
D
Developers
Search…
For
A for flow allows a block of code to be executed once for each item in an array. You can change the order of iteration by using array transformers such as .sorted() or .reversed() on the source data. Additionally, nested loops are fully supported.
If you want to iterate over dictionary, use map flow instead.

Syntax

Basic syntax of for flow is as follows:
1
{[ for [property-name] in [statement] ]}
2
Body, optionally using {{ value }}
3
{[/]}
Copied!
With the following required attributes:
  • property-name - the newly created property where iterated data is stored
  • statement - statement to be evaluated to retrieve data for the iterator. Array is expected
For example, a for flow be used to create lists, menus, and similar structures from sourced data. Let's assume we have a variable users defined that contains following data:
1
[{
2
"name": "Jiri",
3
"type": "member"
4
}, {
5
"name": "Artem",
6
"type": "admin"
7
},{
8
"name": "Ydus",
9
"type": "member"
10
},{
11
"name": "Oskar",
12
"type": "visitor"
13
}
Copied!
You can iterate on user data by defining a new variable user where each item in the array gets stored in each iteration:
1
<h1>Team Members</h1>
2
<ul>
3
{[ for user in users ]}
4
<li>{{ user.name.capitalized() }} ({{ user.type }})</li>
5
{[/]}
6
</ul>
Copied!
With each iteration, data in user is different, resulting in the following output:
1
<h1>Team Members</h1>
2
<ul>
3
<li>JIRI (Member)</li>
4
<li>ARTEM (Admin)</li>
5
<li>YDUS (Member)</li>
6
<li>OSKAR (Visitor)</li>
7
</ul>
Copied!
Last modified 7mo ago
Copy link
Contents
Syntax