Skip to content

Loop Examples ​

Iteration with q:loop - arrays, ranges, and lists.

All Examples ​

Loop Types ​

Range Loop ​

Iterate over a numeric range:

xml
<q:loop type="range" var="i" from="1" to="5">
  <p>Number {i}</p>
</q:loop>

Array Loop ​

Iterate over arrays:

xml
<q:loop type="array" var="fruit" items='["apple", "banana", "orange"]'>
  <li>{fruit}</li>
</q:loop>

Array with Index ​

Access the current index:

xml
<q:loop type="array" var="item" index="idx" items="{myArray}">
  <p>{idx}: {item}</p>
</q:loop>

List Loop ​

Iterate over delimited strings:

xml
<q:loop type="list" var="city" items="NYC,London,Tokyo" delimiter=",">
  <span>{city}</span>
</q:loop>

Range with Step ​

Control iteration step:

xml
<q:loop type="range" var="i" from="0" to="10" step="2">
  <p>Even: {i}</p>
</q:loop>

Quantum Framework - Simplicity over configuration