<:while expr:> [ <:break:> ] [ <:continue:> ] <:/while:>
This tag evaluates the expression expr. If the expression is true, it executes all of the things inside the tag. Then it repeats this process until the expression is false. It is functionally identical to the Python while statement.
This tag is vulnerable to infinite loops, unless you do something inside the tag to change the value of the expression, the tag will execute indefinitely, until the SkunkWeb server calls a timeout and raises an error. For example, this STML will cause an infinite loop:
<:set myVar `1`:> <:while `myVar`:> hello, i'm looping <:/while:>
There are two special tags which work the same way they do inside a <:for:> tag: <:break:> and <:continue:>. The <:break:> tag will cause an immediate exit from the <:while:> tag. The <:continue:> tag will cause an immediate return to the top of the <:while:> tag, where it will evaluate the expression again and continue executing if the expression is true. For example, either of these STML blocks will print ``looping'' 100 times:
<:set myVar `1`:> <:while `myVar <= 100`:> looping <:set myVar `myVar + 1`:> <:/while:>
<:set myVar `1`:> <:while `1`:> looping <:if `myVar > 100`:> <:break:> <:set myVar `myVar + 1`:> <:/if:> <:/while:>