Download the PHP package daun/statamic-latte without Composer

On this page you can find all versions of the php package daun/statamic-latte. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package statamic-latte

Statamic Latte

Use the Latte templating language on Statamic sites.

Features

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.

Antlers

Latte

Installation

To change any of the addon's settings, publish its config file:

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

Statamic Tags can be used via the native s: tag.

Unlike Antlers, Latte does not hoist loop item keys into scope. The canonical pattern in Latte is to capture the tag output in a variable and loop over that directly. You can do that by using parentheses to wrap any tag:

Or capture output into a variable using the as param:

Arguments

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

Pagination

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

Subexpressions

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

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.

Forms

In Latte, form:create returns the form object rather than rendered markup, so you build the <form> in Latte and loop the fields yourself. Capture it with as::

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

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

Statamic Modifiers can be used as filters in Latte:

HTML fields

Latte properly escapes every printed value, which is what you want for a title but not for a markdown field. Fields whose fieldtype renders HTML during augmentation — bard, markdown, redactor — are recognized and printed as markup, so |noescape is not needed:

Resolving values

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

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:

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.

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 & 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.

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:

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 & Slots

Latte composes templates with {embed} and {block}: 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 alias for {block}, so you can use slot terminology on both sides of an embed:

{slot} behaves exactly like {block}, so 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:

Scoped slots

Slot content sees two sets of variables, much like scoped slots in Vue or snippets in Svelte:

That lets a partial render a slot once per item in a loop while the caller decides what each item looks like:

The filled slot replaces the inline default for every row; without a fill, the default renders for every row. If a name exists on both sides, the partial's value wins.

To give a slot an explicit interface instead of exposing the whole loop scope, define it with parameters and render it with {include}:

The caller fills it the same way, with {slot row}…{$cell}…{/slot}.

Conditional content

Iftext

Latte's built-in n:ifcontent omits an element when it renders no output at all. Empty markup still counts as output, though, so a wrapper around an empty <p> or a Bard field that rendered nothing but <p>&nbsp;</p> survives.

The iftext tag tests for visible content instead. Tags are stripped from the rendered output before the emptiness check — think innerText where n:ifcontent is innerHTML:

Elements that render on their own — images, embeds, form controls — count as content even though they hold no text:

It works as a paired tag too, optionally with {else}:

The elements that count as content on their own are img, picture, svg, video, audio, iframe, embed, object, canvas, script, hr, table, form, input, button, select, textarea, progress and meter. Adjust the list in a service provider if your markup needs it:

Caching

Cache

Use the cache tag to cache parts of a view.

Nocache

The nocache tag can be used to exempt part of a view from static caching. Both caching strategies are supported.

Nesting

The cache and nocache tags can be nested in either direction. A nocache region inside a cache block stays dynamic even when the surrounding fragment is served from cache:

Components

Latte templates support the <x-component> syntax. A single tag resolves at compile time to either a Latte or a Blade component. In case of a conflict, the Latte template wins.

A Latte component is a .latte template under the components/ view directory (<x-forms.button> → components/forms/button.latte). Its tag is desugared to a native {embed}, so the template receives the attributes as variables and renders slots as blocks. Anything without a matching template falls back to a Blade component (class, anonymous or vendor), rendered at runtime.

Attributes

Attributes can be static strings, dynamic PHP expressions, or bare booleans. For Latte components they become variables in the template; for Blade components, any attributes not declared as constructor params flow into the $attributes bag.

Backing class (optional)

A Latte component may have a backing class extending Daun\StatamicLatte\Components\Component for logic. Constructor parameters are filled from the tag's attributes, and data() is spread into the template's variables. Without a class, a component is just its template (anonymous).

Slots

Latte components use named and default slots, which compile to {embed} blocks. Fill a named slot with <x-slot:name> (or <x-slot name="name">); the remaining body fills the default slot. A slot that is omitted falls back to the {slot …} content defined in the component template, and slot content is evaluated in the caller's scope.

Blade components accept a body as the default slot ({{ $slot }}), captured as a pre-rendered string and echoed directly. Named slots work too: each <x-slot:name> becomes a Blade ComponentSlot ($name, with isEmpty()/isNotEmpty() and its own $name->attributes).

Control attributes

Latte's n: control attributes work on components:

Cascade variables

Latte views receive the page through $page only; its fields are not repeated as variables. This differs from Antlers, where all page fields are available as variables.

To get Statamic's own behaviour back, set cascade to full in config/statamic-latte.php:

License

MIT


All versions of statamic-latte with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
miko/laravel-latte Version ^3.0
statamic/cms Version ^6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package daun/statamic-latte contains the following files

Loading the files please wait ...