How to calculate values and format numbers in templates
Hubhus includes built-in calculators that allow you to perform mathematical and percentage calculations directly inside templates, booking forms, automations, and HTML components.
On this page
Jump to any section using the links below
Hubhus includes built-in calculators that allow you to perform mathematical and percentage calculations directly inside templates, booking forms, automations, and HTML components. These tools are useful for calculating totals, discounts, VAT, fees, or any other dynamic values. This article explains how to use each calculator type and how to format the resulting numbers.
1. Basic calculations using @calc
Table of Contents
The simplest way to perform a calculation is the @calc[term]@endcalc expression.
Example:
This evaluates the expression and outputs the result.
Supported operations include addition, subtraction, multiplication, division, and parentheses.
Use this when you only need a single expression and do not require formatted output.
2. Using <hh-calculator> for complex expressions
The <hh-calculator> component provides a more flexible way to evaluate expressions and format the result. It supports:
Multiple operations
Parentheses
Precision control
Custom decimal separators
Example:
The output is formatted using the selected precision and decimal separator.
Use this when you need clean, formatted output for emails or templates.
3. Percentage calculations with <hh-calculator.percentage>
Hubhus also provides a percentage calculator for common percentage expressions.
Example:
This supports expressions such as:
“x% of y”
“x% discount on y”
“Add x% to y”
This component is ideal for dynamic quotes, VAT, discounts, or commissions.
4. Formatting numbers with <hh-number.format>
When you need to format numeric output, especially currency, you can use:
This lets you control:
Decimal precision
Input and output decimal separators
Consistent formatting across templates
Use this when you need readable currency values or standardized numeric formatting.
5. Decimal separators and precision
All calculators allow you to specify:
This ensures the value renders exactly as required.
Common patterns:
For Danish formatting:
decimalSeparator=","For international formatting:
decimalSeparator="."For currency:
precision="2"
Make sure all connected calculations use matching settings for consistent output.
6. Using calculations in booking forms
Calculations can be used inside booking form HTML components or confirmation texts.
Common use cases include:
Showing dynamically calculated prices
Summing selected add-ons
Calculating estimated time or duration
Displaying totals during confirmation steps
Place calculator components in:
Part 3 (confirmation step)
Part 4 (after booking is completed)
Or inside HTML components reused across forms
Complex logic can also be combined with JavaScript and saved into hidden fields if needed.
7. Displaying calculated prices in emails
All calculator outputs can be used inside email templates, such as:
Or with percentage calculations:
This ensures emails show accurate, dynamic values even when calculations depend on custom fields or booking choices.
Summary
Hubhus calculators provide powerful tools for generating dynamic numeric values inside templates:
@calc[…]@endcalcfor simple expressions<hh-calculator>for formatted expressions<hh-calculator.percentage>for percentage operations<hh-number.format>for formatting and rounding
These tools can be used in emails, booking forms, automations, HTML components, and internal templates to produce clean, reliable, and dynamic output.
? Common searches
web form • form setup • booking form • form builder
? Also known as
web form • input form • data capture
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article