How to calculate values and format numbers in templates

Modified on Wed, 6 May at 7:14 AM

How to calculate values and format numbers in templates

Hubhus includes built-in calculators for performing math and percentage calculations directly in templates, booking forms, automations, and HTML components — without external code.

TL;DR

Simple calc: @calc[(2+2)*3]@endcalc. Formatted calc: <hh-calculator precision="2" decimalSeparator=",">(1250.75 + 249.25) / 2</hh-calculator>. Percentage: <hh-calculator.percentage>25% of %lead_price%</hh-calculator.percentage>. Number format: <hh-number.format input-decimal-separator="." output-decimal-separator="," decimals="2" />. Use with lead field placeholders for dynamic pricing.

4 calculation tools

1

@calc — basic calculation

The simplest calculator. Supports +, -, *, /, and parentheses. Example: @calc[(%lead_price% * 1.25)]@endcalc — multiply price by 1.25 (add 25% VAT). Output is raw number without formatting. Use when you only need the value without decimal control.

2

hh-calculator — formatted calculation

Supports the same operations as @calc but with precision and formatting control. Attributes: precision="2" (decimal places), decimalSeparator="," (Danish comma), thousandsSeparator=".". Example:
<hh-calculator precision="2" decimalSeparator=",">%lead_price% + %lead_fee%</hh-calculator>Use for currency output in emails and webpages.

3

hh-calculator.percentage — percentage calculations

Specialized for percentage expressions. Supports: "x% of y", "x% discount on y", "Add x% to y". Example:
<hh-calculator.percentage precision="2" decimalSeparator=",">25% of %lead_price%</hh-calculator.percentage>Ideal for VAT calculations, discounts, commissions, and dynamic quotes.

4

hh-number.format — number formatting

Format an existing numeric value without calculating. Attributes: input-decimal-separator, output-decimal-separator, decimals. Example:
<hh-number.format input-decimal-separator="." output-decimal-separator="," decimals="2">%lead_price%</hh-number.format>Use to ensure consistent currency display when the stored value uses a different decimal format.

Read more

Full example: price calculation in email templates

Sum of two lead fields:

Your total price is:
<hh-calculator precision="2" decimalSeparator=",">
    %lead_base_price% + %lead_installation_fee%
</hh-calculator> kr.

Percentage discount applied:

Applied discount:
<hh-calculator.percentage precision="2" decimalSeparator=",">
    10% discount on %lead_total_price%
</hh-calculator.percentage> kr.

VAT calculation (add 25%):

Price incl. VAT:
<hh-calculator precision="2" decimalSeparator=",">
    %lead_price% * 1.25
</hh-calculator> kr.

Using calculations in booking forms

Calculator components can be placed inside booking form HTML components or confirmation texts. Common use cases:

  • Showing dynamically calculated prices during the booking flow
  • Summing selected add-ons or extras
  • Calculating estimated duration or hours
  • Displaying totals at the confirmation step

Where to place calculator components in booking forms:

  • Part 3 (confirmation step) — show price summary before the customer submits
  • Part 4 (after booking is completed) — show final receipt
  • Inside HTML components that are reused across multiple booking forms

Important: Decimal separators must be consistent across all connected calculations. Use decimalSeparator="," for Danish formatting and decimalSeparator="." for international formatting — do not mix within the same calculation chain.

Common searches

calculate price • format number • hh-calculator • percentage calculation • VAT calculation • decimal separator • currency format • @calc

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article