-
Notifications
You must be signed in to change notification settings - Fork 12
Templates
This page documents the technical usage of the template editor in Settings → Templates.
- Visual Mode: WYSIWYG with toolbar, drag & drop snippets, and other format actions.
- Code Mode: edit HTML/Twig directly (CodeMirror syntax highlighting + autocomplete).
Important: If you write complex Twig logic in Code Mode and then switch to Visual Mode, code can be removed. Visual Mode only preserves valid HTML structures.
- Snippets are shown in the left panel and can be inserted via drag & drop.
- Available snippets depend on the selected template type.
Simple logic is represented with data-* attributes on HTML elements and transformed to Twig blocks on the backend before rendering.
data-repeat="collectionPath"data-repeat-as="itemVar"- optional:
data-repeat-key="keyVar"(for key/value arrays)
Example outside a table:
<span data-repeat="miscPositions" data-repeat-as="position">
[[ position.description ]]: [[ position.totalPrice ]] €<br>
</span>Example inside a table:
<tr data-repeat="apartmentPositions" data-repeat-as="position">
<td>[[ position.startDate|date('d.m.Y') ]]</td>
<td>[[ position.totalPrice ]] €</td>
</tr>data-if="expression"
Example:
<tr data-if="address.company">
<td>[[ address.company ]]</td>
</tr>The system supports the existing placeholder syntax:
-
[[ ... ]]→ expression -
[% ... %]→ block -
[# ... #]→ comment
Example:
[% for reservation in reservations %]
[[ reservation.booker.lastname ]]
[% endfor %]- Autocomplete shows suggestions for variables when you are inside of
[[ ]]or by using shortcutctrl + space - Suggestions are type-aware (Entity, Collection, Array, Scalar, Date).
- Selecting collection suggestions can generate a
data-repeatblock automatically. - date types are inserted with
|date("d.m.Y")automatically
All PDF types provide header/footer snippets (<div class="header">, <div class="footer">).
Note: If a template would result in more than one PDF page, you should place the footer at the top of your template otherwise it will be visible only on the last page of the generated PDF.