Template Syntax
Target Audience
The target audience of this document are developers or persons with at least some software development experience.
Template Engine
We are using Pebble Templates to populate email and document templates with data. Please be aware that we are still using version 3.0.4 of Pebble Templattes, because some of our custom extions are not yet compatible with the latest version of Pebble.
Important Blocks
Loops
{% for offer in offers %}
{% endfor %}If Blocks
{% if test == 'teststring' %}
{% elseif test == 'asdf' %}
{% else %}
{% endif %}Important Modifiers
trim
{{ " mein text " | trim }}numberformat
By default a decimal point number will be printed with maximum precission - in some cases you might want to use a custom format.
Formatting a number as integer
{{ item.itemCount | numberformat('#') }}Formatting a number with exactly two decimal points and a local specific thousand separator
{{ item.itemCount | numberformat('#,##0.00') }}nl2br
Sometimes you might encounter a multi-line string, where the lines are separated by a newline-character. When you want to render such a string within an HTML template (keeping the line breaks) you have to convert the newline characters to HTML br (line break) elements.
{{ address | nl2br }}Custom Macros
Gender specific text
{{greeting(guest.gender, 'Hallo Herr', 'Hallo Frau', 'Hallo')}} {{ guest.lastName}}Currency format
{{money(offer.unitPriceSummary.amount, offer.unitPriceSummary.currency)}}Custom Extensions
In certain situations the WYIWYG template editor would remove (or complain about) invalid markup - e.g. when wrapping loops or if conditions around table cells or table rows. In such cases you can add the for or if condition directly onto the HTML element as an attribute.
h-for Attribute
<tr h-for="item in offer.shoppingCart">
<td>{{ item.itemCount | numberformat("#") }} x {{ item.inHouseService.name.$locale }}</td>
<td>{{ money(item.unitPriceSummary.amount + item.unitPriceSummary.excludedTaxAmount, item.unitPriceSummary.currency) }}</td>
</tr>h-if
<div h-if="address != null">
{{ address }}
</div>