Anvil | Smiths Smiths | Register Register | Login Login |
Search:
Show links Show tools Show tree | Previous document Next document | njet.org > Anvil > Documentation > Language reference > Templates > Tags > <foreach>

<foreach>

  <foreach 
      [ label="symbollabel" ] 
      [ index="list-of-assignable-exprindex" ]
      [ key="list-of-assignable-exprkey" ]
      [ value="list-of-assignable-exprvalue" ]
      (expr|in)="expriterable" >
    statement *
  </foreach>

A ``foreachยดยด tag iterates through the enumeration returned by value yielded by expression and assigns, on each cycle, index, key and element to given assignable expressions. See foreach statement.

Attributes:

label
Optional label for the use of break and continue statements.
index
Optional list of assignable expressions where the numerical index of loop is stored, starting from zero.
key
Optional list of assignable expression where the key of retrieved element is stored, depending of value being iterated.
value
Optional list of assignable expression where the retrieved elements are stored, depending of value being iterated.
expr
Expression yielding iterable value. Mutually exclusive with in.
in
Expression yielding iterable value. Mutually exclusive with expr.

See also  | Tags  | Statement tags
Contributes notes:
Add a note
What's new | Anvil