Handlebars is a popular Javascript framkework for personalising content and building reusable HTML template blocks. CrossEngage uses HandleBars to allow you to easily personalise content by allowing you to access user attributes, event data, voucher data or product information within messages.

Read more about the HandleBars framework and its built-in helpers here.

With CrossEngage Templates

When creating a template in CrossEngage, you can type HandleBars syntax directly within your template and CrossEngage will render it upon dispatch. For example:

Hello {{user.[traits.firstName]}}, how are you doing today?

This will render the template upon message dispatch as follows:

Hello Sarah, how are you doing today?

Please note that all attributes/properties in Handlebars are written in camelCase. This means that the first word is written entirely lowercase, while subsequent words start with an Uppercase character, without any space or separator e.g 'firstName' or 'optOutLink'.

During message dispatch, CrossEngage will now automatically render the first name of each user that will receive the message.

Handlebars HTML-escapes the equals sign. If your Handlebar includes an equals sign, use three curly brackets on each side to prevent escape. For emaple, if β€˜traits.favouriteProduct' has a value of "123cacdsf=asd", you can use it as {{{traits.favouriteProduct}}}

With External Templates

When using Third-Party Integrations for your messages, it is often possible to use Templates from the Integration Provider, such as Mailjet or SendGrid. To use an External Template, you can add Placeholders to the Template and fill in the value later, using Handlebars or Value Mapping.

The syntax for placeholders is defined by each integration. For example, in SendGrid, the placeholder can be used by wrapping it in % sign:

    <p>Hi %FIRSTNAME%.</p>

Always use descriptive names for placeholders, as it will make it easier to recognise and use the correct Handlebars for the placeholders.

For External Templates, CrossEngage allows you to map Values on Placeholders, with or without Handlebars.

To use a Handlebar expression for Value Mapping, select the "Handlebars" option, write the Handlebar expression, and provide the Placeholder.

Which data can be accessed with Handlebars?

Handlebars can pull data from Users, Events and Products. You can find more details in each relevent section, under Helper Functions.

Vouchers can also be used in CrossEngage using Handlebars. For more details, please click here.

Helper Functions

Helper Functions are simple Javascript functions, that can be used inside Handlebars. They can retrieve and process data from the databases, and format it for messages. Helper functions can also perform some specialized tasks, for example, you can add an "Unsubscribe" link in your messages using the Opt Out Helper Function.

Last updated