Aller au contenu principal

TWIG

  • We provide a custom subset of Twig, a PHP-based template engine, designed for generating text-based formats like HTML and PDF from template .twig files
  • Templates support basic Twig constructs:
    • {{ variable }} to output values
    • {% … %} for control logic such as loops or conditionals.

Template Syntax & Usage​

  • A typical .twig file might render dynamic values like:

    twigKopierenBearbeiten<h1>Welcome to {{ shopName }}</h1>
    {% for product in products %}
    <li><a href="{{ product.href }}">{{ product.name }}</a></li>
    {% endfor %}

    where variables and loops drive dynamic content.

  • Variable access uses dot notation (e.g. {{ user.firstName }}), and you can define or reassign variables within blocks using {% set … %}

  • Comments in templates are marked with {# … #} and are excluded from the output, useful for documentation or temporary deactivation


Key Features​

  • Our engine only supports a limited subset of standard Twig features, tailored to its platform; supported syntax is documented in the reference
  • Templates can produce various formats, not just HTML—examples include invoices or other PDF-based documents.

Quick Reference​

FeatureSyntax Example
Output variable{{ shopName }}
Loop over list{% for item in items %} … {% endfor %}
Assign variable{% set foo = 'bar' %}
Comment{# Note: this is a comment #}