Expressions are an essential part of Mahalo. They consist of anexpression string and a scope in which they will be executed.With their ability to watch for changes in their evaluatedresult expressions are a very powerful feature of the framework.
That beeing said most of their magic is happening behind the scenesand their implicit usage should be rare. For common use casesMahalo provides higher level access to them. Most notably ina Template.
Syntax
The syntax of Mahalo expressions is similar JavaScript itself.However there are the following differences.
Variables
You cannot access any global or local variables since expressionsare evaluated in a scope. So every identifier will be treated asa property of the expressions scope.
To go deeper into an object you can of course use the dot andbracket syntax just like in JavaScript. In case the propertyof the scope you're looking for contains characters that arenot allowed in valid JavaScript identifiers you can start with thebracket syntax prefixed with a dot.
${ .['§property'] }
Comparisons
All comparisons will be strictly equal on evaluation but the syntaxonly knows loose operators (==, !=, <=, >=, <, >).
Filters
You can use the | symbol to apply a filter to the expression leftto it. See the filters A list of available
Unallowed stuff
Statements like if, for, while, try are not allowed.Also there are no declarations or assignments of any kind possible inMahalo expression. You can only use single line statements. The ;symbol is also invalid.
Expressions are an essential part of Mahalo. They consist of anexpression string and a scope in which they will be executed.With their ability to watch for changes in their evaluatedresult expressions are a very powerful feature of the framework.
That beeing said most of their magic is happening behind the scenesand their implicit usage should be rare. For common use casesMahalo provides higher level access to them. Most notably ina Template.
Syntax
The syntax of Mahalo expressions is similar JavaScript itself.However there are the following differences.
Variables
You cannot access any global or local variables since expressionsare evaluated in a scope. So every identifier will be treated asa property of the expressions scope.
To go deeper into an object you can of course use the dot andbracket syntax just like in JavaScript. In case the propertyof the scope you're looking for contains characters that arenot allowed in valid JavaScript identifiers you can start with thebracket syntax prefixed with a dot.
Comparisons
All comparisons will be strictly equal on evaluation but the syntaxonly knows loose operators (==, !=, <=, >=, <, >).
Filters
You can use the | symbol to apply a filter to the expression leftto it. See the filters A list of available
Unallowed stuff
Statements like if, for, while, try are not allowed.Also there are no declarations or assignments of any kind possible inMahalo expression. You can only use single line statements. The ;symbol is also invalid.
{ default } from mahalo/expression/index