For loop (basic) Last updated: 30. May 2026
This example demonstrates a basic for loop in a hash template, including the use of continue to skip an item and break to exit the loop early.
Example
Code Test.hash
<h1>Testing a loop</h1>
<ul>
#{
let items = ["a", "b", "c", "d", "e", "f", "g"];
for(let item of items)
{
if (item == "a") continue; // Skips this item and continues to next
if (item == "f") break; // Breaks and exits for loop
}#
<li>#item#</li>
#}#
</ul> Output
<h1>Testing a loop</h1>
<ul>
<li>b</li>
<li>c</li>
<li>d</li>
<li>e</li>
</ul>