latte-templateslisted
Install: claude install-skill nette/agent-plugins
## Latte Templating System
Latte is a secure templating engine with context-aware escaping, intuitive syntax, and powerful template inheritance.
```shell
composer require latte/latte
```
### Basic Syntax
```latte
{* this is a comment *}
<ul n:if="$items"> {* n:attribute *}
{foreach $items as $item} {* tag *}
<li>{$item|capitalize}</li> {* variable with filter *}
{/foreach}
</ul>
```
### Printing Variables
```latte
{$name} {* prints escaped variable *}
{$user->name} {* object property *}
{$items[0]} {* array access *}
{='hello'|upper} {* expression with filter *}
{$html|noescape} {* disable escaping (use carefully!) *}
```
Latte uses **context-aware escaping** — output adapts to where the variable is printed. In `<script>` context, arrays and objects are automatically serialized to JSON:
```latte
{* Arrays auto-serialize to JSON inside <script> *}
<script type="application/ld+json">{$schemaData}</script>
<script>
let config = {$config};
</script>
```
Never use `json_encode()` in PHP + `|noescape` for this — Latte handles serialization and escaping safely on its own.
### Filters
Filters modify output, written after `|`:
```latte
{$title|upper} {* HELLO *}
{$text|truncate:100} {* shortens to 100 chars *}
{$price|number:2} {* formats number *}
{$date|date:'j. n. Y'} {* formats date *}
{$name|lower|capitalize}