EVML supports creation of basic function declarations within a single and unbroken <?ev..?> script block.


    function name([parameter [..., parameter]]){
        [return [expression];]


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.


    function hello(name){
        return 'Hello ' + name;

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.

    var person = {
        hello: function(name){
            return 'Hello ' + name;

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.