If you use Cheetah, please support the project and register by clicking here:


9.6 #break and #continue

Syntax:

#break
#continue

These directives are used as in Python. #break will exit a #for loop prematurely, while #continue will immediately jump to the next iteration in the #for loop.

In this example the output list will not contain ``10 - ''.

#for $i in range(15)
#if $i == 10
  #continue
#end if
$i - #slurp
#end for

In this example the loop will exit if it finds a name that equals 'Joe':

#for $name in $names
#if $name == 'Joe'
  #break
#end if
$name - #slurp
#end for

If you use Cheetah, please support the project and register by clicking here: