PHPackages                             daun/statamic-latte - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. daun/statamic-latte

ActiveStatamic-addon[Templating &amp; Views](/categories/templating)

daun/statamic-latte
===================

Use Latte templates on Statamic sites

2.0.0(2w ago)44721[1 issues](https://github.com/daun/statamic-latte/issues)[1 PRs](https://github.com/daun/statamic-latte/pulls)MITPHPPHP ^8.3CI passing

Since Mar 10Pushed 1w ago1 watchersCompare

[ Source](https://github.com/daun/statamic-latte)[ Packagist](https://packagist.org/packages/daun/statamic-latte)[ RSS](/packages/daun-statamic-latte/feed)WikiDiscussions main Synced yesterday

READMEChangelog (8)Dependencies (17)Versions (14)Used By (0)

Statamic Latte
==============

[](#statamic-latte)

Use the [Latte](https://latte.nette.org/en/) templating language on [Statamic](https://statamic.com/) sites.

Features
--------

[](#features)

- Use Statamic's built-in tags and modifiers
- Resolve the current layout from entry data
- Render Antlers inline where useful

Why Latte?
----------

[](#why-latte)

Latte is simple, safe, and fast. Templates are compiled. Expressions are plain PHP. Output values are escaped automatically, in every context. Latte adds concise inline control structures and smart attributes for expressive templating.

- **PHP syntax, no new language**: Expressions and conditions are plain PHP, so there's little mental context-switching between template and application code.
- **Context-aware escaping**: Latte understands HTML and escapes differently inside text, attributes, JavaScript or URLs.
- **Concise &amp; expressive**: Control flow lives directly on the html elements, clarifying intent and reducing nesting.
- **Smart html attributes**: Booleans, `null`, arrays and data attributes render correctly with no manual string juggling, similar to modern frontend frameworks.
- **Fast**: Templates compile to PHP once and run as native code on every request.

**Antlers**

```
{{ if entries | count }}

    {{ entries }}
        {{ if link }}
            {{ title }}
        {{ else }}
            {{ title }}
        {{ /if }}
    {{ /entries }}

{{ /if }}
```

**Latte**

```

  link} href={$entry->link}>
    {$entry->title}

```

Installation
------------

[](#installation)

```
composer require daun/statamic-latte
```

Usage
-----

[](#usage)

Once installed, you can use Latte views in your frontend. Save or rename your views using the extension `.latte` and reference them as usual. Antlers and Latte views can live side-by-side as long as view names are unique.

### Tags

[](#tags)

[Statamic Tags](https://statamic.dev/tags) can be used via the native `s:` tag.

```
Found {s:collection:count in:pages /} pages:
```

Unlike Antlers, Latte does not hoist loop item keys into scope. Inside a loop, the item itself is exposed as `$value`. Access fields explicitly with `$value->title` over a bare `{title}`.

```
{s:collection:pages}
  {$value->title}
{/s:collection:pages}
```

Assign tag output using parentheses:

```
{var $entries = (s:collection from: pages, sort: title)}
{foreach $entries as $entry}{$entry->title}{/foreach}
```

Or capture output into a variable using the `as` param:

```
{s:collection from: pages, as: entries}
  {foreach $entries as $entry}{$entry->title}{/foreach}
{/s:collection}
```

Use self-closing tags to output simple scalar return values from tags:

```
{s:link to: "snacks"/}
```

#### Arguments

[](#arguments)

Nested parameters are supported, with either `=>` or `:` separators. They accept variables, literals and expressions.

```
{var $entries = (s:collection from: pages, status:is => draft)}
{var $entries = (s:collection from: pages, title:contains:Christmas)}
{var $entries = (s:collection from: pages, title:contains:$request->title)}
```

#### Pagination

[](#pagination)

Paginated tags return a Laravel paginator. Loop it directly and fetch meta from its built-in methods.

```
{s:collection:pages as: entries, paginate: 10}
  {foreach $entries as $entry}{$entry->title}{/foreach}
  Page {$entries->currentPage()} of {$entries->lastPage()}
{/s:collection:pages}
```

#### Subexpressions

[](#subexpressions)

Wrap a tag in parentheses to use it inline as a plain expression — in `{var}`, conditions, filters, `foreach`, and Latte's `n:` attributes:

```
{var $entries = (s:collection from: pages, sort: title)}
{if (s:collection:count in: pages) > 1}many{/if}
{(s:link to: "snacks")|upper}

{$entry->title}
many
Snacks
```

#### Tags consuming nested content as input

[](#tags-consuming-nested-content-as-input)

Some tags transform their tag-pair body instead of returning data (e.g. `widont`, `obfuscate` ). Hand it to the tag via the `content:` argument.

```
{s:widont content: $entry->headline /}
```

### Forms

[](#forms)

Through the proxy, `form:create` returns the form's *data* rather than rendered markup, so you build the `` in Latte and loop the fields yourself. Capture it with `as:`:

```
{s:form:create as: form, in: contact}

        {foreach $form->fields as $field}
            {$field->display}

            {if $field->error}{$field->error}{/if}
        {/foreach}
        Send

{/s:form:create}
```

Check submission state with the scalar `form:success` and the boolean `form:errors` gate:

```
{s:form:success in: contact}{$value}{/s:form:success}

{s:form:errors in: contact}
    Please fix the errors below.
{/s:form:errors}
```

To list individual error messages, read them from the `form:create` capture (`$form->errors`, or `$form->error->{handle}` for a field's first error) — the `form:errors` pair is a boolean gate here, not an iterator.

### Modifiers

[](#modifiers)

[Statamic Modifiers](https://statamic.dev/modifiers) can be used as filters in Latte:

```
{$title|upper|truncate:50}
```

### Resolving values

[](#resolving-values)

Most values are augmented and stringified automatically on print, so you rarely need to unwrap them yourself:

```
{$title}
{$author->name}
```

As an escape hatch for the cases where you hold a raw `Value`/`LabeledValue` object (e.g. when passing one into a function or comparison), the `resolve` and `r` helpers and filter return the underlying value:

```
{resolve($author)} or {r($author)}
{$author|resolve}
```

### Mixing Latte and Antlers

[](#mixing-latte-and-antlers)

If you ever need to combine Latte and Antlers code, you can use the `antlers` tag in your Latte views to render Antlers code inline. This can be useful for complex built-in tags or quick prototyping by copy-pasting examples from the docs.

```
Rendered in Latte: {$title}

{antlers}
    Rendered in Antlers: {{ title }}
{/antlers}
```

### Layout

[](#layout)

Just like in Antlers templates, the correct layout file will be used based on the data available in your entries and blueprints.

By default, it will look for `/resources/views/layout.latte`, but you can configure specific entries and collections to use different layouts instead by setting `layout: other_layout` on the entry or collection config file.

### Sections &amp; Yields

[](#sections--yields)

Use the `section` and `yield` tags to define content in one place and output it in another. They map directly to Antlers' identical tags.

```
{* layout *}

{yield breadcrumbs /}

{* template *}

{section breadcrumbs}
    {$entry->title}
{/section}
```

Use the self-closing form `{yield 'name' /}` when there's no fallback. To provide default content for when no section was defined, use the paired form:

```
{yield breadcrumbs}
    Homepage
{/yield}
```

Sections and yields share Statamic's underlying content store, so they interoperate freely across Latte, Antlers and Blade templates: a section defined in an Antlers partial can be yielded in a Latte layout, and vice versa.

### Embeds &amp; Slots

[](#embeds--slots)

Latte composes templates with [`{embed}`](https://latte.nette.org/en/template-inheritance#toc-horizontal-reuse)and [`{block}`](https://latte.nette.org/en/template-inheritance): a partial defines named, fillable regions with `{block}`, and the embedding template overrides them inside `{embed}`.

For parity with the component/slot vocabulary used by Antlers and Blade, `{slot}` is provided as an **exact alias for `{block}`**. It is a pure synonym — same parsing, same rendering — so you can use slot terminology on both sides of an embed:

```
{* partials/figure.latte *}

    {slot caption}Default caption{/slot}

```

```
{* template *}

{embed file 'partials.figure', src: $image->url, alt: $image->alt}
    {slot caption}A custom caption{/slot}
{/embed}
```

Because `{slot}` is identical to `{block}`, the two are interchangeable everywhere (including layouts and `{extends}`) and you can freely mix them. Omitting a slot in the embed falls back to the default content defined in the partial.

The `n:slot` attribute is also available (mirroring `n:block`) and works on both sides:

```
{* partials/figure.latte *}

Default caption

{* template *}

{embed file 'partials.figure'}
    A custom caption
{/embed}
```

### Caching

[](#caching)

#### Cache

[](#cache)

Use the `cache` tag to cache parts of a view.

```
{cache for: '10 minutes'}
    {foreach $stocks as $stock}
        {$stock->fetchPrice()}
    {/foreach}
{/cache}
```

#### Nocache

[](#nocache)

The `nocache` tag can be used to exempt part of a view from [static caching](https://statamic.dev/static-caching).

```
{include 'partials.nav', handle: main}

{nocache}
    {if $logged_in}
        Welcome back, {$current_user->name}
    {else}
        Hello, Guest!
    {/if}
{/nocache}

{block content}{/block}
```

#### Limitations

[](#limitations)

The `nocache` tag is only supported for application-level static caching. Full file-based caching requires JavaScript for `nocache` to work, which isn't yet implemented in this addon. See [Caching Strategies](https://statamic.dev/static-caching#caching-strategies) for details.

Nesting `cache` and `nocache` is also not yet supported. The following **will not work**:

```
{cache}
    this will be cached
    {nocache}
        this will remain dynamic
    {/nocache}
    this will also be cached
{/cache}
```

License
-------

[](#license)

[MIT](https://opensource.org/licenses/MIT)

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance92

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~117 days

Recently: every ~194 days

Total

8

Last Release

19d ago

Major Versions

1.3.0 → 2.0.02026-06-14

PHP version history (2 changes)1.0.0PHP ^8.1

2.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/31ac2b3787ded290b6bac87b937abf4f267483e4da64731bfb256a942bb669ca?d=identicon)[daun](/maintainers/daun)

---

Top Contributors

[![daun](https://avatars.githubusercontent.com/u/22225348?v=4)](https://github.com/daun "daun (151 commits)")

---

Tags

lattestatamicstatamic-addontemplatesviewsnetteviewlattestatamic

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/daun-statamic-latte/health.svg)

```
[![Health](https://phpackages.com/badges/daun-statamic-latte/health.svg)](https://phpackages.com/packages/daun-statamic-latte)
```

###  Alternatives

[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135224.7k7](/packages/statamic-rad-pack-runway)[statamic/cms

The Statamic CMS Core Package

4.8k3.6M985](/packages/statamic-cms)[statamic/statamic

Statamic

829179.5k](/packages/statamic-statamic)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3416.9k](/packages/duncanmcclean-statamic-cargo)[marcorieser/statamic-livewire

A Laravel Livewire integration for Statamic.

23111.5k15](/packages/marcorieser-statamic-livewire)[contributte/latte

Extra contrib to nette/latte

121.5M2](/packages/contributte-latte)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
