The Dollar and Semicolon Expression Operators
The dollar and semicolon expression operators allow for more advanced syntax constructs.
$-operator
The $-operator is an alias for the buffer.get() vipermethod. It must be followed by a buffer name. The buffer name can optionally be enclosed in quotes. When using quotes, you have the possibility of including the buffer scope.
Smartsite SXML |
![]() |
---|---|
$varname is equivalent to buffer.get(varname) $'varname' is equivalent to buffer.get('varname') $'page:varname' is equivalent to buffer.get('page:varname') which can also be written as buffer.get('varname, page) |
Example usage:
Smartsite SXML |
![]() |
---|---|
{buffer.set(a,16)} <se:if expression="$a GT 10">Greater than 10</se:if> => Greater than 10 {sys.eval( $a * 4 )} => 64 |
;-operator
The ;-operator is a statement separator. It can be used to separate multiple expressions. Only the expression to the right of the semicolon will be used for the expression result. The left part of the expression can be used to manipulate internal state.
The left part of the expression is always be executed before the right part.
Smartsite SXML |
![]() |
---|---|
{sys.eval(buffer.set(a,3); math.pow($a,2) + math.pow($a+1,2) )} => 25 {sys.eval(buffer.set(a,3); (buffer.get(a)+1) * buffer.get(a) )} => 12 {sys.eval(buffer.set(a,3); ($a+1) * $a )} => 12 |
Viper syntax constraints
Note that a viper is defined as a single vipermethod enclosed in curly braces {}.
Therefore, these contructs are not valid:
Smartsite SXML |
![]() |
---|---|
{$b} => Not valid: vipermethod missing {buffer.set(year,2008); datetime.getdaysinyear($year)} => Not valid: semicolon not allowed here |
To make them valid, enclose them in a vipermethod like sys.eval().
Example
An example that displays the number of days until new-year:
Smartsite SXML |
![]() |
---|---|
{sys.eval( buffer.set(dt,datetime.now()); buffer.set(ny,convert.todate((datetime.getyear($dt)+1)+'-01-01')); math.floor(datetime.daysbetween($ny,$dt))+' days until new-year !' )} |