The for statement creates a statement loop governed by three expressions, enclosed in parentheses and separated by semicolons.


    for (initialization; condition; expression) {
        code block


initialization An expression or variable declaration. Generally used to start a counter. This expression may optionally declare new variables with the var keyword.
condition An expression to be evaluated before each iteration. If this expression evaluates to true, the statement block is executed.
expression An expression to be evaluated at the end of each iteration. Generally used to increment a counter.
code block One or more statements that execute as long as the condition evaluates to true. In EVML for loop statements must be enclosed within a block statement (enclosed in curly brackets {...}).

Note: Unlike JavaScript, EVML for loops require an initialisation, condition and expression


The following are valid:

    for (var i=0; i<10; i++) {

Generally you want to output some HTML, in which case the following example may make more sense:

    for (var i=0; i<page.children.length; i++) { 
        var childpage = page.children[i];
    <h3>{{ childpage.title }}</h3>
<?ev } ?>

See also and for...of loops.

COVID-19 NOTICE – Business as Usual
Evance continues to provide all services and support throughout this difficult period. See our full statement here