- Theme Engine
- Design Principles
- Templates
- EVML Reference
- Output
- Comments
- Operators
- Statements and Declarations
- Built-in Functions
- Built-in Objects
- Account
- Address
- Array
- Boolean
- Branch
- Cart
- CartLine
- Category
- CategoryCollection
- CategoryFilter
- CategoryFilterCollection
- CategoryFilterOption
- CategorySearch
- Collection
- Color
- Contact
- Currency
- Date
- Discount
- Dom
- Event
- EventCollection
- EventSlot
- Image
- Layout
- Locale
- Money
- Number
- Object
- Page
- PageCollection
- PageSearch
- PageSharer
- Pagination
- Postage
- Price
- PriceDiscount
- Product
- ProductCollection
- ProductCustomisation
- ProductDownload
- ProductMedia
- ProductMediaFrame
- ProductPrice
- ProductSearch
- ProductSpecification
- ProductSpecificationValue
- ProductVariation
- ProductVariationOption
- RecentlyViewed
- RegExp
- Request
- Review
- ReviewCollection
- Search
- SearchCollection
- SearchResult
- String
- Tag
- Template
- Url
- Website
- EV Tags
- CSS Pre-processor
- Ajax API
for
The for statement creates a statement loop governed by three expressions, enclosed in parentheses and separated by semicolons.
Syntax
<?ev
for (initialization; condition; expression) {
code block
}
?>
Where...
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
Examples
The following are valid:
<?ev
for (var i=0; i<10; i++) {
print(i);
}
?>
Generally you want to output some HTML, in which case the following example may make more sense:
<?ev
for (var i=0; i<page.children.length; i++) {
var childpage = page.children[i];
?>
<h3>{{ childpage.title }}</h3>
<?ev } ?>