- 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
function
EVML supports creation of basic function declarations within a single and unbroken <?ev..?>
script block.
Syntax
function name([parameter [..., parameter]]){
statement;
[return [expression];]
}
Where...
name | The function name. |
parameter | The name of an argument to be passed to the function. |
statement | The statements to be executed when the function is called. |
return | Optionally you can return from the function causing the function to terminate. |
expression | The expression to return. |
Example
<?ev
function hello(name){
return 'Hello ' + name;
}
print(hello('Bob'));
?>
Function expressions
It is also possible to create a function using an expression. The main difference between a function expression and a function statement is the function's name can be omitted to create anonymous functions.
<?ev
var person = {
hello: function(name){
return 'Hello ' + name;
}
};
print(person.hello('Bob'));
?>
Note EVML is a template language, function
support is fairly primitive and restricted to the scope of the template.
This means you cannot currently include a file containing a function for use in another template. Functions do not currently
support parameters with default values.