In this article, we will explain how to disable auto-escaping within a block and display double curly brackets by using tags in your email templates.
autoescape
By default, Brevo escapes the HTML (and JS) content of all variables. This means any HTML passed within a variable will be escaped and printed as text. For example, if your variable content is <h1>My title</h1>, then your template would output exactly this text within your email: <h1>My title</h1> rather than outputting the phrase “My title” formatted as an H1 title.
The autoescape
tag controls the current auto-escaping behavior. Since Brevo templates autoescape HTML by default, you will need to apply this tag to disable auto-escaping within a particular block. The block should be closed with an endautoescape
ending tag.
We will review a common example where disabling autoescape
may be useful. Let’s say that you pass products in a variable, but each product requires unique formatting.
If autoescape
is used like this:
{% autoescape off %}{{ params.my_html }}{% endautoescape %} |
Then, auto-escaping will be disabled for the variable {{ params.my_html }}
. Now, if your variable content is <h1>My title</h1>
, it will display as an H1 title.
Input | Output | |
Without the autoescape tag |
{{ params.my_html }} |
<h1>My title</h1> |
With the autoescape tag | {% autoescape off %}{{ params.my_html }}{% endautoescape %} |
My title |
verbatim
Brevo Template Language placeholders are formatted as {{ params.variable }}
. When using double curly brackets around text {{ like this }}
in an email template, Brevo will automatically identify this part as a template language element.
The verbatim tag allows you to use double curly brackets in your email templates without them being recognized as a template language element. To escape {{ }}
and print these symbols directly in your email, wrap them in this tag:
{% verbatim %} {{ Print variable }} {% endverbatim %} |
This text will appear fully in your email as: {{ Print variable }}
.
⏩ What's next?
- How to customize your transactional emails
- Modify the formatting of your placeholder with filters
- Limitations when using HTML for your email campaigns
🤔 Have a question?
If you have a question, feel free to contact our support team by creating a ticket from your account. If you don't have an account yet, you can contact us here.
If you’re looking for help with a project using Brevo, we can match you with the right certified Brevo expert partner.