Twig Templating in Eliona

Introduction to Twig Templating

Eliona uses -> [External Link] Twigarrow-up-right, a powerful and flexible templating engine for JavaScript and PHP, for the dynamic generation of message content. Twig allows you to define templates that are used by external messaging services such as SMS, Google Chat, Slack, or email.

Twig.js Version

The current implemented version of Twig.js in Eliona is 1.17.1. The full documentation and implementation notes are available at the following links:


Twig Syntax and Functions

Twig syntax allows you to insert and process dynamic content in templates. Some frequently used functions are:

Outputting Variables

{{ alarm.val }}  {# Outputs the value of the alarm #}
{{ asset.name }}  {# Displays the name of the affected asset #}

Using Conditions

{% if alarm.prio == 1 %}
    Attention: High priority!
{% else %}
    Normal alarm.
{% endif %}

Using Loops

Formatting Strings


Available Templates and Variables in Eliona

Eliona offers different template types for various use cases:

Each of these templates supports specific variables that are dynamically populated with the respective data.


Ticket Template

Available Variables

The ticket template can be used for the automated generation of ticket notifications. The following variables are available:

Example of a Ticket Template


Alarm Template

Available Variables

The alarm template is based on a test data set and contains extensive details about alarms and their associated assets.

Example of an Alarm Template


User Template

The User Template allows access to user-specific information—especially for notification purposes (e.g., email, chat, or alarm forwarding). It can be used in all templates where user data is available.

Available Variables

Example of a User Template


Password Reset Template

Available Variables

The password reset template is used in Eliona to send users an email with a link to reset their password.

Example of a Password Reset Template

circle-exclamation

yAxis Formatter

The yAxis Formatter determines the display of the axis label in charts. It shows the current value of the data series along with additional attribute information.

Available Variables for the yAxis Formatter

  • {{unit}} – Unit of the value (e.g., °C, %, kWh)

  • {{value}} – The current value of the data series

  • {{attribute}} – Name of the attribute

  • {{gai}} – Global Asset ID

  • {{aggregatedDataField}} – Data field for the aggregation

  • {{aggregatedDataRaster}} – Raster with which the data was aggregated

  • {{aggregatedDataType}} – Type of aggregation (e.g., average, sum)

Example of a yAxis Formatter

Result for temperature data: → 22.5 °C (Room temperature)


Legend Template

The Legend Template determines the display of the legend label in charts. It describes the data series by combining the name of the asset or data series with attribute information.

Available Variables for the Legend Template

  • {{unit}} – Unit of the value (e.g., °C, %, kWh)

  • {{attribute}} – Name of the attribute

  • {{gai}} – Global Asset ID

  • {{name}} – Name of the asset or data series

  • {{aggregatedDataField}} – Data field for the aggregation

  • {{aggregatedDataRaster}} – Raster with which the data was aggregated

  • {{aggregatedDataType}} – Type of aggregation (e.g., average, sum)

Example of a Legend Template

Result for a temperature sensor: → Air conditioner Office 1 - Room temperature (°C)


Conclusion

Twig.js enables a flexible and efficient use of templates in Eliona. By using Twig variables and functions, personalized content can be generated for tickets, alarms, and emails. More information on Twig syntax is available in the official documentation: -> [External Link] Twig.js Wikiarrow-up-right.

Last updated