nette/claude-code/latte-templates
- community
Checking that the SKILL.md file is still in the repository.
Invoke before creating or modifying .latte files, even for single-line changes. Provides Latte syntax, tags, filters, n:attributes, layouts, template inheritance, AJAX snippets, extensions, and Nette integration. Also trigger when user mentions Latte by name.
Install
npx vskill@latest install nette/claude-code/latte-templatesSKILL.md
Latte Templating System
Latte is a secure templating engine with context-aware escaping, intuitive syntax, and powerful template inheritance.
Basic Syntax
Printing Variables
Latte uses context-aware escaping — output adapts to where the variable is printed. In <script> context, arrays and objects are automatically serialized to JSON:
Never use json_encode() in PHP + |noescape for this — Latte handles serialization and escaping safely on its own.
Filters
Filters modify output, written after |:
Common filters: upper, lower, capitalize, truncate, number, date, noescape, escapeUrl, stripHtml, trim, replace, first, last, length, sort, reverse
The filter | applies to the entire expression before it. Parentheses around PHP operators (like ??) before a filter are unnecessary:
See the complete filter reference for all available filters.
n:attributes
Pair tags can be written as HTML attributes:
Conditions and Loops
{if} / {elseif} / {else}, {foreach} and {for} work as expected. What is Latte-specific:
Variables
Template Inheritance
Layout template (`@layout.latte`):
Child template:
Including Templates
Blocks
Other Common Tags
| Tag | Description | |
|---|---|---|
{do expression} | Execute without output | |
{php expression} | Obsolete alias for {do} – a single expression only. Real PHP code needs RawPhpExtension | |
{dump $var} | Debug dump (Tracy) |
See the complete tag reference for all available tags.
Smart HTML Attributes (Latte 3.1)
Applies only when the whole attribute value is one {...} expression (title={$t} or title="{$t}"). In a mixed value (title="foo {$t}") none of it applies – null becomes '', an array becomes "Array". n:attr follows the same rules, so {if} / n:attr wrappers around attributes are obsolete.
| Kind | Attributes | Value handling | |
|---|---|---|---|
| bool | allowfullscreen async autofocus autoplay checked controls default defer disabled formnovalidate inert ismap itemscope loop multiple muted nomodule novalidate open playsinline readonly required reversed selected | truthy → bare name; falsey (false, null, 0, '', []) → omitted | |
| tristate | contenteditable draggable spellcheck writingsuggestions | bool → the keywords "true" / "false"; null omits the attribute | |
| valued bool | hidden popover | flag like a bool, but a non-empty value survives (hidden="until-found"); falsy is tested first, so '0' omits it rather than rendering an invalid value | |
| list | accesskey class headers itemprop ping rel role sandbox | array → space-separated | |
| style | style | array → prop: value; … | |
| data | data-* | array / stdClass → JSON; bool → "true" / "false" | |
| aria | aria-* | bool → "true" / "false"; array → space-separated | |
| plain | everything else | string/int/float/Stringable printed; null omits the attribute; array, bool or other object → E_USER_WARNING and the attribute is dropped |
In list/aria arrays a plain item is used as-is, a keyed item yields the key only if its value is === true (active => 1 renders 1, not active); items with null, false, 0, '' are skipped, an all-skipped array omits the attribute. In style, a keyed item is skipped by the same rule, so opacity => 0 vanishes ('0px' survives).
A real filter defeats smart handling – it stringifies the value: class={$arr|noescape} renders class="Array". Keep smart attributes filter-free; toggle, json, nocheck and accept are compile-time hints, not filters, and are safe.
Traps:
- URL attributes are exempt (
href,src,action,formaction,<object data>): Latte
appends an internal checkUrl filter, so href={$url} with null renders href="", and an array gives href="Array" with only a PHP notice. Use href={$url?|nocheck} for the drop (this also skips the URL safety check).
- Tristate attributes distinguish three states:
trueandfalserender the keyword,
null drops the attribute. That matters, because "missing" and ="false" mean different things — contenteditable="false" disables editing inside an editable region, whereas a missing attribute inherits from the parent.
Prefer class={[...]} and smart attributes over n:class / n:attr
Since 3.1 the attribute forms cover almost everything the n: ones did, so new templates should reach for them first. Neither n:class nor n:attr is deprecated in Latte, and there is one case only n:attr can express (below), so this is a preference, not a removal.
Do not rewrite existing templates mechanically — two differences change the rendered output:
- A keyed item applies only when its value is `=== true`. With any other truthy value the
value is printed instead of the key, which is silent. Keep the ternary rather than moving the condition into a key.
- `n:class` de-duplicates the list (
array_unique),class={[...]}does not — the same
class listed twice survives after the rewrite.
n:class additionally rejects an array variable (n:class="$arr" → class="Array"; use class={$arr}) and a sibling class="…" on the same tag (CompileException); both fail loudly.
The one case n:attr still owns is a dynamic set or name of attributes, which no static attribute can express:
Migration from 3.0 – changed: null used to print =""; data-/aria- bools printed "1"/""; data- arrays printed a space-separated list; on* values were JSON-encoded. $engine->setFeature(Latte\Feature::MigrationWarnings, true) warns on every affected attribute; the |accept filter silences it per value.
Latte in Nette Applications
Template Organization Strategy
Keep templates with presenters:
Layout placement follows presenter organization:
The more specific a layout, the closer it sits to the presenters it serves; whether it extends the enclosing one is up to it. Keep such chains short: a part that only some pages share usually fits better through {include} or {define} than through another layout level.
Template Partial Patterns
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/nette/skills/latte-templates/SKILL.md
Popularity
- Repository stars
- 37
- Repository forks
- 4
- 7-day trend score
- 18
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 18 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/nette/claude-code/latte-templates)