XF 2.1 Absolute value in template?


Active member
How can I get an absolute value? Something like {{ abs(-10) }} doesn't work. Do I have to use an if statement and then multiply by negative 1 if < 0?


Active member
I know xf:if could be used but setting the current value of the variable by using xf:set might be more useful if the variable will be always used as an absolute value in the template.

<xf:set var="$myVar" value="{{(($myVar >= 0 )?:-1) * $myVar }}"/>