> For the complete documentation index, see [llms.txt](https://wplake.gitbook.io/advanced-views/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wplake.gitbook.io/advanced-views/templates/template-engines.md).

# Template engines

{% hint style="info" %}
Advanced Views comes with a few template engines pre-built, giving you the freedom to choose one that is closer to your needs.&#x20;
{% endhint %}

You can setup the default template engine in the plugin settings, and it'll be used for all the new *Layouts* and *Post Selections*.&#x20;

Meanwhile, you can choose any template engine inside a particular item, as well as mix items with different template engines - e.g., create a *Post Selection* with Twig and choose the item *Layout* made with Blade.&#x20;

This way, you can safely give a try to a new template engine, or gradually migrate the old codebase. &#x20;

## Comparison

| Feature             | vanilla PHP | Twig                                                                                                                                                                                 | Blade   |
| ------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------- |
| Minimum PHP version | -           | 7.4 (as WordPress)                                                                                                                                                                   | 8.2.0   |
| Shortcuts support   | partial     | yes                                                                                                                                                                                  | yes     |
| Output auto-escape  | no          | yes                                                                                                                                                                                  | yes     |
| Available functions | any PHP     | only [built-in](/advanced-views/templates/template-engines/twig.md#built-in-twig-features) or [registered](/advanced-views/customization/filters-and-hooks.md#custom-twig-functions) | any PHP |

### 1. PHP

```php
<? foreach ($categories["value"] as $index => $term_item): ?>
    <a target="<?= esc_html($term_item["target"]); ?>" class="acf-view__categories-link" href="<?= esc_html($term_item["value"]); ?>">
        <?= esc_html($term_item["linkLabel"] ?: $term_item["title"]); ?>
    </a>
<? endforeach; ?>
```

Pros:

* well-known syntax
* full access to WordPress functions
* shortcuts for [opening tags](https://www.php.net/manual/en/language.basic-syntax.phptags.php) and [control syntax](https://www.php.net/manual/en/control-structures.alternative-syntax.php)

Cons:

* no output auto-escape
* verbose constructions

### 2. Twig

{% hint style="info" %}
[Twig](https://twig.symfony.com/) is developed by the [Symphony framework](https://symfony.com/) creators.
{% endhint %}

```twig
{% for index, term_item in categories.value %}
    <a target="{{ term_item.target }}" class="acf-view__categories-link" href="{{ term_item.value }}">
        {{ term_item.linkLabel|default(term_item.title) }}
    </a>
{% endfor %}
```

Pros:

* short and clean syntax
* output auto-escape

Cons:

* alternative construction and function names
* no access to WordPress functions (requires manual registration)&#x20;

### 3. Blade

{% hint style="info" %}
[Blade](https://laravel.com/docs/13.x/blade) is developed by the [Laravel framework](https://laravel.com/) creators.
{% endhint %}

```blade
@foreach ($categories["value"] as $index => $term_item)
    <a target="{{ $term_item["target"] }}" class="acf-view__categories-link" href="{{ $term_item["value"] }}">
        {{ $term_item["linkLabel"] ?: $term_item["title"] }}
    </a>
@endforeach
```

Pros:&#x20;

* short and clean syntax (with names matching PHP)&#x20;
* full access to WordPress functions&#x20;
* output auto-escape

Cons:&#x20;

* requires PHP 8.2+
