Twig templating in Eliona
Introduction to Twig Templating
Eliona uses -> [External Link] Twig, a powerful and flexible templating engine for JavaScript and PHP, for dynamically generating message content. Twig makes it possible to define templates that are used by external messaging services such as SMS, Google Chat, Slack, or email.
Twig.js Version
The currently 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 makes it possible to insert and process dynamic content in templates. Some commonly used functions are:
Output variables
{{ alarm.val }} {# Outputs the value of the alarm #}
{{ asset.name }} {# Displays the name of the affected asset #}Use conditions
{% if alarm.prio == 1 %}
Warning: High priority!
{% else %}
Normal alarm.
{% endif %}Use loops
Format strings
Available templates and variables in Eliona
Eliona offers various template types for different use cases:
Each of these templates supports specific variables that are filled dynamically with the respective data.
Ticket Template
Available variables
The ticket template can be used to automatically generate ticket notifications. The following variables are available:
Example of a ticket template
Alarm Template
Available variables
The alarm template is based on a test dataset and contains extensive details about alarms and their associated assets.
Example of an alarm template
User Template
The User Template provides 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
yAxis Formatter
The yAxis Formatter determines the display of the axis label in charts. It displays the current value of the data series together 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}}– Grid 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}}– Grid 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 conditioning Office 1 - room temperature (°C)
Conclusion
Twig.js enables flexible and efficient use of templates in Eliona. By using Twig variables and functions, personalized content for tickets, alarms, and emails can be generated. Further information about Twig syntax is available in the official documentation: -> [External Link] Twig.js Wiki.
Last updated
Was this helpful?