Generate text from Handlebars template
The “Generate text from template (Handlebars)” service task produces text based on a template. The Handlebars engine injects data into the template and returns the final text.
Input parameters
Provide the following fields as task input:
{
"template": "string",
"content": { "key1": "value1", "key2": "value2" }
}
Explanation:
template
: Text template to fill dynamically. Use Handlebars expressions such as{{key1}}
.content
: JSON object containing the values to insert into the template.
Output
The task returns the generated text.
{
"status": 200,
"response": {
"result": "Final generated text."
}
}
Explanation:
status
: Status of the operation (200
indicates success).result
: Final text based on the template and content.
JSONata examples
{
"template": "<h1>Hello {{name}}</h1><p>Your order: {{order}}</p>",
"content": {
"name": "Jane Doe",
"order": "12345"
}
}
Available Handlebars helpers
Helper | Description | Example |
---|---|---|
dateTimeFormat |
Formats an ISO-8601 date into a localized date and time. | {{dateTimeFormat '2024-12-22T10:30:00Z' 'en-US' 'Europe/Berlin'}} |
multiply |
Multiplies two numbers. | {{multiply 5 3}} |
currentDateTime |
Returns the current date and time in the specified format. | {{currentDateTime 'en-US' 'Europe/Berlin'}} |
toGermanDate |
Converts a date in YYYY-MM-DD to the German date format. |
{{toGermanDate '2024-12-22'}} |
replace |
Replaces a string with another value. | {{replace 'Pantarey GmbH' 'GmbH' 'AG'}} |
add |
Adds two numbers. | {{add 10 5}} |
round |
Rounds a number to a defined number of decimal places. | {{round 12.3456 2}} |
currency_eur |
Formats a number as a Euro amount in the German locale. | {{currency_eur 1234.56}} |
addDaysToCurrentDate |
Adds a given number of days to the current date. | {{addDaysToCurrentDate 5}} |
month_name |
Returns the month name based on a date. | {{month_name '2024-12-22'}} |
greaterThan |
Checks whether the first number is greater than the second. | {{#greaterThan 10 5}}Greater{{else}}Not greater{{/greaterThan}} |
lessThan |
Checks whether the first number is less than the second. | {{#lessThan 3 5}}Less{{else}}Not less{{/lessThan}} |
greaterOrEqualThan |
Checks whether the first number is greater than or equal to the second. | {{#greaterOrEqualThan 5 5}}Greater or equal{{else}}Not greater or equal{{/greaterOrEqualThan}} |
lessOrEqualThan |
Checks whether the first number is less than or equal to the second. | {{#lessOrEqualThan 3 5}}Less or equal{{else}}Not less or equal{{/lessOrEqualThan}} |
numberFormat |
Formats a number using the German number format. | {{numberFormat 1234567.89}} |
Notes
- Ensure the template and data match so all placeholders can be resolved.
- Ideal for generating HTML emails, personalized documents, or other text content.
- See the Handlebars guide for more details.
Tip
Test templates in the Handlebars Playground before using them in production.