> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alumio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Render a Template

> Practical examples for rendering output with the Render a Template Transformer, using variable interpolation, loops, conditionals, and built-in filters.

### Overview

The Render a Template Transformer renders Twig templates using supplied data to produce formatted output strings, such as order confirmations, emails, CSV rows, or HTML/XML blocks. For safety, only the `if` and `for` tags are supported, along with a fixed set of filters: `abs`, `batch`, `capitalize`, `default`, `escape` (`e`), `first`, `format`, `join`, `keys`, `last`, `length`, `lower`, `nl2br`, `number_format`, `replace`, `reverse`, `round`, `striptags`, `title`, `trim`, `upper`, and `url_encode`.

### Render a confirmation message

```twig theme={null}
Dear {{ customer.firstName }} {{ customer.lastName }}, your order #{{ order.id }} totaling {{ order.total|number_format(2) }} {{ order.currency }} has been received and is being processed.
```

Sample data:

```json theme={null}
{
  "customer": { "firstName": "Maria", "lastName": "Janssen" },
  "order": { "id": "ORD-10293", "total": 149.5, "currency": "EUR" }
}
```

Output:

```text theme={null}
Dear Maria Janssen, your order #ORD-10293 totaling 149.50 EUR has been received and is being processed.
```

### Loop over items to build a CSV block

```twig theme={null}
{% for item in order.items %}{{ item.sku }},{{ item.name }},{{ item.quantity }},{{ item.price|number_format(2) }}
{% endfor %}
```

Sample data:

```json theme={null}
{
  "order": {
    "items": [
      { "sku": "SKU-001", "name": "Wireless Mouse", "quantity": 2, "price": 19.99 },
      { "sku": "SKU-002", "name": "USB-C Cable", "quantity": 5, "price": 8.5 }
    ]
  }
}
```

Output:

```text theme={null}
SKU-001,Wireless Mouse,2,19.99
SKU-002,USB-C Cable,5,8.50
```

### Use a conditional fallback

```twig theme={null}
{% if customer.address.street is defined %}
{{ customer.address.street }} {{ customer.address.houseNumber }}, {{ customer.address.postalCode }} {{ customer.address.city }}
{% else %}
No address on file
{% endif %}
```

<Note>
  Only the `if` and `for` tags are available in the Render a Template Transformer. Constructs like `{% set %}` are not supported.
</Note>

### Text formatting filters

| Filter | Example | Result |
| - | - | - |
| `trim` + `title` | `{{ product.name\|trim\|title }}` | `Wireless Keyboard` |
| `default` + `upper` | `{{ product.brand\|default('Unknown Brand', true)\|upper }}` | `UNKNOWN BRAND` |
| `lower` + `capitalize` | `{{ product.category\|lower\|capitalize }}` | `Electronics` |

### List filters

| Filter | Example | Result |
| - | - | - |
| `join` | `{{ order.items\|join(', ') }}` | `Mouse, Keyboard, Monitor` |
| `first` | `{{ order.items\|first }}` | `Mouse` |
| `last` | `{{ order.items\|last }}` | `Monitor` |
| `length` | `{{ order.items\|length }}` | `3` |
| `reverse` | `{{ order.items\|reverse\|join(', ') }}` | `Monitor, Keyboard, Mouse` |
| `batch` | `{% for group in order.items\|batch(2) %}...{% endfor %}` | groups of 2 |
| `keys` | `{{ product.attributes\|keys\|join(', ') }}` | `color, size, material` |

### Numeric filters

| Filter | Example | Result |
| - | - | - |
| `abs` | `{{ invoice.amount\|abs }}` | `149.5678` |
| `round` | `{{ invoice.amount\|abs\|round(2) }}` | `149.57` |
| `number_format` | `{{ invoice.amount\|abs\|number_format(2) }}` | `149.57` |
| `format` | `{{ '%s costs %.2f EUR'\|format(product.name, invoice.amount\|abs) }}` | `Wireless Keyboard costs 149.57 EUR` |

### Safety and escaping filters

| Filter | Example | Result |
| - | - | - |
| `striptags` + `nl2br` | `{{ review.comment\|striptags\|nl2br }}` | HTML tags removed, line breaks kept |
| `escape` (`e`) | `{{ review.comment\|escape }}` | HTML entities escaped |
| `replace` | `{{ review.comment\|replace({'great': 'excellent'}) }}` | word replaced |
| `url_encode` | `{{ review.authorEmail\|url_encode }}` | URL-safe string |

<Tip>
  Use the **Run Test** option in Alumio after each change to validate the rendered output against a representative entity before enabling the configuration.
</Tip>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.