Use Handlebar Helpers
Optimize the configuration of your email templates by using handlebar helpers. Add logic into your email templates by using conditional helpers. You can also use other handlebar helpers such as string, number, and date formats.
Conditional Helpers
Some common conditional function helpers with examples are listed in the table below:
Function | Description | Example |
---|---|---|
eq |
Checks if two elements are equal. |
This example shows how to modify an email's subject based on a task's outcome (approve or reject)
|
neq |
Checks if two elements are not equal. |
This example shows how to compare a business object’s value and modify an email.
|
gt |
Greater than operator |
The example below shows how to mark an email's subject as Important! if the total amount of an expense report is greater than $10,000.
The example below compares an array object's size and conditionally shows expense items only if the number of items is greater than 1.
|
and |
Checks if two conditions are true |
This example shows how to add a special category section into the email's content if the travel category is critical and if the traveler is an executive.
|
String, Date, and Number Format Helpers
Some common string, date, and number format helpers with examples are listed in the table below:
Function | Description | Example |
---|---|---|
capitalizeFirst |
Capitalizes the first character of the value. |
If value is "string.example", the output will be "String.example". |
cut |
Removes all values of arg from the given string. |
If value is "String with spaces", the output will be "Stringwithspaces". |
join |
Joins an array, iterator or an iterable with a string. |
If value is the list ['a', 'b', 'c'], the output will be the string "a // b // c". |
lower |
Converts a string into all lower case. |
If value is 'String Helper Example', the output will be 'string helper example'. |
upper |
Converts a string into all upper case. |
If value is 'Hello', the output will be 'HELLO'. |
replace |
Replaces each substring of a string that matches the literal target sequence with the specified literal replacement sequence. |
If value is "String ...", the output will be "String example". |
dateFormat |
Returns the date in the specified format. Parameters:
|
Examples:
|
numberFormat |
Returns the number in the specified format. Parameters:
|
|
Note:
Handlebars is a superset of Mustache and Mustache templates are compatible with Handlebars.See Handlebars.