With TWIG, you can dynamically build content in Aivie themes, format values, perform calculations, and use conditions. TWIG is primarily used in template files for emails, landing pages, forms, and system messages.
How does a TWIG filter work?
A filter is appended to a value with a vertical bar:
{{ value|filter }}
For example:
{{ firstname|default('Guten Tag') }}
{{ title|upper }}
Multiple filters can be combined:
{{ title|trim|upper }}
Edit text
The following filters are available for text, among others:
| Filter | Usage |
|---|---|
upper | Convert text to uppercase |
lower | Convert text to lowercase |
title | Start words with uppercase letters |
capitalize | Capitalize the first letter |
trim | Remove spaces at the beginning and end |
replace | Replace text |
striptags | Remove HTML tags |
nl2br | Convert line breaks to HTML |
length | Determine the number of characters or elements |
default | Use a default value if no value is present |
Example:
{{ company|default('deinem Unternehmen')|trim }}
Format numbers and perform calculations
Twig supports the standard arithmetic operators:
{{ a + b }}
{{ a - b }}
{{ a * b }}
{{ a / b }}
{{ a // b }}
{{ a % b }}
{{ a ** b }}
Additionally, the following filters and functions are helpful:
| Filter or function | Usage |
|---|---|
int | Convert a value to an integer |
abs | Determine the absolute value |
round | Round a number |
number_format | Format a number for output |
min() | Determine the smallest value |
max() | Determine the largest value |
Example with Swiss number format:
{{ (price|int * quantity|int)|number_format(2, '.', "'") }}
You can round a number like this:
{{ value|round(2) }}
{{ value|round(0, 'ceil') }}
{{ value|round(0, 'floor') }}
Use date values
With date and date_modify, you can format or modify date values:
{{ "now"|date("d.m.Y") }}
{{ dateValue|date("d.m.Y") }}
{{ dateValue|date_modify("+30 days")|date("d.m.Y") }}
Process lists and arrays
The following filters are available for lists, among others:
| Filter | Usage |
|---|---|
first | Output first element |
last | Output last element |
join | Join elements into text |
split | Split text into elements |
keys | Output keys of an array |
merge | Merge lists or arrays |
slice | Use a slice |
sort | Sort elements |
reverse | Reverse order |
batch | Split elements into groups |
Example:
{{ tags|join(', ') }}
Use conditions and loops
With conditions, you can display content depending on a value:
{% if points|int >= 100 %}
Du hast mindestens 100 Punkte erreicht.
{% else %}
Dir fehlen noch einige Punkte.
{% endif %}
You can output lists with a loop:
{% for item in items %}
{{ item }}
{% endfor %}
You can also safely calculate a sum with a loop:
{% set total = 0 %}
{% for value in values %}
{% set total = total + (value|int) %}
{% endfor %}
{{ total|number_format(2, '.', "'") }}
Some functions are blocked for security reasons
Some filters can accept executable functions as arguments. Aivie blocks them to prevent unauthorized code from being executed. For example:
mapfilterreduce
Functions that could access system configuration, database, files, or internal PHP functions are also blocked.
If you need a specific calculation or data transformation that cannot be implemented with the available options, contact us. We will then check whether a secure, clearly limited filter can be added for this purpose.
Important: Not every text field in the Aivie editor processes TWIG. For normal personalization of emails, you continue to use the available Aivie or Mautic tokens.
In short
Aivie supports the standard TWIG functions for text, numbers, dates, lists, conditions, and loops. Dangerous functions and filters with freely executable callbacks are blocked in uploaded themes for security reasons.
You can find more information on the TWIG website.

