---
url: /twig.md
---
# Twig syntax

## Filters

Standard Twig filters — https://twig.symfony.com/doc/2.x/filters/index.html

## Functions

Standard Twig functions — https://twig.symfony.com/doc/2.x/functions/index.html

### newsletter\_subscribed

**Parameters of newsletter\_subscribed**

| Attribute | Description |
|---|---|
| **email** | recipient email address |

```twig
{% if not newsletter_subscribed(user.email) %}
    Subscribe to the newsletter!
{% endif %}
```

## Simplia filters

In addition to standard Twig filters, Simplia templates provide custom filters.

### Price formatting

| Filter | Description | Example |
|---|---|---|
| `cena` (price) | format price with currency | `{{ product.price\|cena }}` |
| `mena` (currency) | format price with currency (alias) | `{{ value\|mena }}` |
| `mena_rounded` (currency rounded) | rounded price with currency | `{{ value\|mena_rounded }}` |

### Text

| Filter | Description | Example |
|---|---|---|
| `orez` (trim) | truncate text to length | `{{ text\|orez(100) }}` |
| `highlight` | highlight search term | `{{ text\|highlight(query) }}` |
| `prvniVelke` (capitalize first) | capitalize first letter | `{{ text\|prvniVelke }}` |
| `diakritika` (diacritics) | remove diacritics | `{{ text\|diakritika }}` |
| `strip` | remove HTML tags | `{{ text\|strip }}` |
| `preg_replace` | regex replacement | `{{ text\|preg_replace('/pattern/', 'replacement') }}` |

### Date

| Filter | Description | Example |
|---|---|---|
| `date_locale` | localized date | `{{ date\|date_locale }}` |
| `relative_date` | relative date (2 days ago) | `{{ date\|relative_date }}` |
| `addWorkingDays` | add working days | `{{ date\|addWorkingDays(3) }}` |

### Images

| Filter | Description | Example |
|---|---|---|
| `imgSrc` | image URL at specified size | `{{ image\|imgSrc(300, 300) }}` |
| `imgSrcSet` | srcset for responsive images | `{{ image\|imgSrcSet }}` |
| `image_proxy` | URL through image proxy | `{{ url\|image_proxy }}` |
| `gravatar` | Gravatar URL for email | `{{ email\|gravatar }}` |
