How to create a Twig snippet plugin for server-side code

What is Twig and why use it?

Twig is a powerful HTML template engine. It offers all the features already available for the rich text editor, such as merge fields, along with other extras (e.g. conditional logic, loops, escaping strings). Zenario core functions can be used in a Twig template.

Comments

Comments can be used to explain how a block of code works, mark different sections or any other reason.

These comments only appear in the source code and are never displayed to users.

To use a comment, put the {# ... #} tags around the text.

Twig snippet comment

Variables

Variables can be set using the {% set %} tag.

Twig snippet variable

These variables may later be used in conditional statements.

Loops

Twig supports looping over items in a sequence.

The following code will display all numbers 0-10 in one row:

Twig snippet numbers 0 to 10

Examples