Maple Engine
Last Updated: 2023-11-04 06:02:43
Variables are defined as { [ VARIABLE ] } where VARIABLE is the name of a variable. To access its value is written as { myVariable }
A collection and it's keys, often referred to as a record-set, are accessed differently and requires the indication of a key name. Keys are indicated through brackets and optional quotes enclosing the key name.
For example, a variable representing an account may have first and last name variables. These values can be accessed as myAccount['FirstName'] or myAccount['LastName']. You can use single, double or no quotes so myAccount['FirstName'] is the same as myAccount["FirstName"] and myAccount[FirstName].
Note: An operator can also compare one variable to another.
Note: Values can also be variables.
{ [ VARIABLE ] [ OPERATOR ] [ VARIABLE|VALUE ] } ... { end }
{ [ VARIABLE ] [ OPERATOR ] [ VARIABLE|VALUE ] } ... { else } ... { end }
Examples
{ myVariable >= 3 } ... { end }
{ myAccount[FirstName] != "John" } ... { end }
{ myAccount[FirstName] = myAccount[LastName] } ... { end }
{ myAccount[FirstName] === myAccount[LastName] } ... { end }
The second example requires quotes because John is explicitly defined.The third and fourth examples are the same.
Maple allows you to write HTML templates using placeholders for functions. A Maple function will always accept one parameter and always returns a value. The value returned usually is either an evaluation or modification of the parameter accepted.
Maple functions are identified by a name and brackets and are defined as FUNCTION( PARAMETER ) where FUNCTION is the maple function name and PARAMETER is a variable passed to it. For example, length( myVariable ) or show( myVariable )
Let's look at some examples of using functions within conditions. A list of functions and their meaning is discussed later.
{ count( accounts ) >= 1 } ... { end }
{ defined( myAccount[FirstName] ) = 1 } ... { end }
Note: All available functions are pre-defined, it is not possible to define your own.