laravel-template-engine 0.5.0

Templates for emails, documents and notifications that your team edits, stored in the database
Documentation
# Template syntax

| You want to | Write |
|---|---|
| Insert a value | `{{ customer.name }}` |
| Show something only sometimes | `{% if order.delivery == "courier" %} … {% else %} … {% endif %}` |
| Check that a value is there | `{% if customer.phone %} … {% endif %}` |
| Repeat for each item of a list | `{% for item in order.items %} {{ item.name }} {% endfor %}` |
| Number the items | `{{ loop.index }}`, and `loop.first`, `loop.last` |
| Show text when a list is empty | `{% for item in order.items %} … {% else %} No items {% endfor %}` |
| A fallback for a missing value | `{{ customer.phone \| default("—") }}` |
| An amount with its currency | `{{ order.total \| money("UAH") }}` → 1 250,00 ₴ |
| A number | `{{ order.weight \| number(2) }}` → 1 250,50 |
| A date | `{{ order.placed_at \| date("%d.%m.%Y") }}` → 03.12.2026 |
| A date with the month's name | `{{ order.placed_at \| date("%d %B %Y") }}` → 03 грудня 2026 |
| The right word for a number | `{{ count }} {{ count \| plural("товар", "товари", "товарів") }}` |
| Change case | `{{ name \| upper }}`, `{{ name \| lower }}`, `{{ name \| title }}` |
| Count a list's items | `{{ order.items \| length }}` |
| A picture the developers added | `<img src="logo" alt="Acme">` |
| A note only for you | `{# this text is not sent #}` |

`plural` takes one form for each of the language's plural categories: two in English
(`"item", "items"`), three in Ukrainian and Polish (`"товар", "товари", "товарів"`).

Date codes: `%d` day, `%m` month, `%B` month name, `%Y` year, `%H:%M` time, `%A` weekday.

Values are escaped in HTML, so a customer's name can never break the email's layout.