November 2018
Intermediate to advanced
404 pages
10h 16m
English
To loop through a collection, you can use the #for tag. For example, you can pass three users in Context:
let context = ["users": ["John", "Angus", "Mary"]]
In the HTML code, you can loop through an array of items using Leaf's #for tag:
<h2>Event Participants</h2>#for(user in users){ <li>#(user)</li> }
Within the #for loop, you could use the following loop variables to handle more complex situation:
The following HTML sample code shows how to use the isLast variable to format the last user in a list:
This year's participants are #for(user in users){ #if(isLast) { ...Read now
Unlock full access