Back to Skills

latte-templates

verified

Invoke before creating or modifying .latte files. Provides Latte syntax, tags, filters, layouts, and extensions.

View on GitHub

Marketplace

nette

nette/claude-code

Plugin

nette

development

Repository
Verified Org

nette/claude-code
29stars

plugins/nette/skills/latte-templates/SKILL.md

Last Verified

January 20, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/nette/claude-code/blob/main/plugins/nette/skills/latte-templates/SKILL.md -a claude-code --skill latte-templates

Installation paths:

Claude
.claude/skills/latte-templates/
Powered by add-skill CLI

Instructions

## 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!) *}
```

### 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}          {* chained filters *}
```

Common filters: `upper`, `lower`, `capitalize`, `truncate`, `number`, `date`, `noescape`, `escapeUrl`, `stripHtml`, `trim`, `replace`, `first`, `last`, `length`, `sort`, `reverse`

For complete filter reference, see [filters.md](filters.md).

### n:attributes

Pair tags can be written as HTML attributes:

```latte
{* These are equivalent: *}
{if $condition}<div>...</div>{/if}
<div n:if="$condition">...</div>

{* Applies to element content only: *}
<div n:inner-foreach="$items as $item">...</div>

{* Applies to tag only (not content): *}
<a href={$url} n:tag-if="$url">Link</a>
```

### Conditions

```latte
{if $stock > 0}
	In stock
{elseif $onWay}
	On the way
{else}
	Not available
{/if}

{ifset $user}...{/ifset}          {* if variable exists *}

{* switch/case *}
{switch $type}
	{case admin}Administrator
	{case user}User
	{default}Guest
{/switch}
```

### Loops

```latte
{foreach $items as $item}
	{$item->name}
{/f

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
8052 chars