#calc & #var
Perform calculations within templates by using the following data helpers:
- #calc
- #var
The #calc data helper performs the defined calculation and outputs the result into the template.
The data helper supports addition, subtraction, division, multiplication and ukvatrate.
Addition
Section titled “Addition”| Values | Data Marker | Output |
|---|---|---|
| 57.50 | {{#calc 5 + 7.50}} | 12.50 |
| search.fee = 100.00land.registration.fee = 7.00 | {{#calc search.fee + land.registration.fee}} | 107.00 |
Subtraction
Section titled “Subtraction”| Values | Data Marker | Output |
|---|---|---|
| 124 | {{#calc 12 - 4}} | 8.00 |
| property.price = 350,000deposit.amount = 30,000 | {{#calc property.price - deposit.amount}} | 320,000.00 |
Division
Section titled “Division”| Values | Data Marker | Output |
|---|---|---|
| 63 | {{#calc 6 / 3}} | 2 |
| deposit.amount = 20,000 | {{#calc deposit.amount / 2}} | 10,000 |
Multiplication
Section titled “Multiplication”| Values | Data Marker | Output |
|---|---|---|
| 99 | {{#calc 9 * 9}} | 81 |
| fees.our.legal.fee = 100 | {{#calc fees.our.legal.fee * 2}} | 200 |
UK VAT
Section titled “UK VAT”settings.ukvatrate can be used to include the current UK VAT rate into calculations
| Data Marker | Output |
|---|---|
| {{#calc fees.our.legal.fee * settings.ukvatrate}} | The legal fees VAT |
| {{#calc fees.our.legal.fee + fees.our.legal.fee * settings.ukvatrate}} | The legal fee including it’s VAT rate |
Australia GST
Section titled “Australia GST”settings.ausgstrate can be used to include the current Australian GST rate into calculations
| Data Marker | Output |
|---|---|
| {{#calc fees.our.legal.fee * settings.ausgstrate}} | The legal fees GST |
| {{#calc fees.our.legal.fee + fees.our.legal.fee * settings.ausgstrate}} | The legal fee including it’s GST rate |
A #var Data Helper can be used to recall previously defined figures within a template.
To use this:
- Define the conditions of the #var, for example:
{{#var $discount = fees.our.legal.fee * 0.2}} - Use the newly created var statement to recall the figure
{{$discount}}will outputfees.our.legal.fee * 0.2
The #abs Data Helper can be used to covert a negative value to a positive.
| Values | Data Marker | Output |
|---|---|---|
| $legalfee = -5 | {{#abs $legalfee}} | 5 |
Greater Than and Less Than Symbols
Section titled “Greater Than and Less Than Symbols”< / > can be used to define an output depending on the value of a field
| Data Marker | Output |
|---|---|
| {{#if $legalfee > 0}} We owe you {{$legalfee}} {{#else}} You owe us {{$Legalfee}}{{#endif}} | If the legal fee is more than 0, output: _We owe you_If the legal fee is less than 0, output: You owe us |