Maths (#calc, #var, #abs, #round, #ceil, #floor)
The maths helpers let you calculate values — for example, working out fees on a form.
Form fee example
Section titled “Form fee example”A common use is calculating a fee as a percentage of a price. Here’s a 2% fee on the purchase price:
{{#var $fee = property.price / 100 * 2}}Our fee (2% of the purchase price) is {{$fee}}.If property.price is 250000, this outputs:
Our fee (2% of the purchase price) is 5,000.00.#calc — calculate and show a value
Section titled “#calc — calculate and show a value”#calc works out a calculation and outputs the result immediately:
{{#calc property.price * 0.02}}- Supports
+,-,*,/and brackets( ). - Follows standard order of operations (BODMAS):
{{#calc 2 * 4 + 4 / 2}}outputs10.00. - Each part must be a number, or a data marker/variable that holds a number.
#var — store a value for later
Section titled “#var — store a value for later”#var calculates a value and stores it in a variable. It doesn’t output anything by itself — output the variable where you need it:
{{#var $deposit = property.price / 10}}A 10% deposit is {{$deposit}}.The right-hand side of the = is a calculation, just like #calc.
#abs — absolute (positive) value
Section titled “#abs — absolute (positive) value”#abs outputs a number without its minus sign — useful for balances that may be negative:
Balance: {{#abs matter.account.office.balance}}#round — round a value
Section titled “#round — round a value”#round rounds a number to a set number of decimal places, either "up" or "down", and stores the result in a variable:
{{#round $rounded = property.price 0 "down"}}Rounded price: {{$rounded}}- The first value is what to round (a number, data marker, or variable).
- The second is the number of decimal places.
- The third is
"up"or"down"(in double quotes).
Like #var, #round doesn’t output anything itself — output the variable afterwards.
#ceil / #floor — round a calculation up or down
Section titled “#ceil / #floor — round a calculation up or down”#ceil evaluates a calculation and rounds the result up toward positive infinity; #floor rounds it down toward negative infinity. Both store the result in a variable and output nothing themselves — just like #var:
{{#ceil $units = (property.price - 25000) / 100}}Units (rounded up): {{$units}}- The right-hand side of the
=is a calculation, exactly like#varand#calc(numbers, data markers, variables,+ - * /, and brackets). - An optional whole number after the calculation sets the decimal places to round at (default
0):{{#ceil $x = 1.2301 2}}gives1.24. - Rounding is a true ceiling/floor, not round-half-up:
#ceilof3.01is4, of3.00is3, and of-2.5is-2.
Why this matters — “per $100, or part thereof” fees. Duty scales that charge per part-unit need a ceiling. Previously this was emulated with a rounding hack; #ceil makes it explicit. For the Tasmanian band ($25,001–$75,000 — $435 plus $2.25 per $100 or part thereof above $25,000):
{{#ceil $units = (property.price - 25000) / 100}}{{#var $f = ($units * 2.25) + 435}}Duty: {{$f}}