Which TWIG functions and filters does Aivie support?

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:

FilterUsage
upperConvert text to uppercase
lowerConvert text to lowercase
titleStart words with uppercase letters
capitalizeCapitalize the first letter
trimRemove spaces at the beginning and end
replaceReplace text
striptagsRemove HTML tags
nl2brConvert line breaks to HTML
lengthDetermine the number of characters or elements
defaultUse 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 functionUsage
intConvert a value to an integer
absDetermine the absolute value
roundRound a number
number_formatFormat 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:

FilterUsage
firstOutput first element
lastOutput last element
joinJoin elements into text
splitSplit text into elements
keysOutput keys of an array
mergeMerge lists or arrays
sliceUse a slice
sortSort elements
reverseReverse order
batchSplit 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:

  • map
  • filter
  • reduce

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.

Für dich da.

Wir bieten dir lokalen Support und Services.

  • Wir unterstützen dich
  • Kostenloser Support per FAQ, Chat oder E-Mail. VIP Support per Video Telefonie.
  • Umgehende Support-Rückmeldung
aivie marketing automatin lokaler support adrian schimpf