Skip to content
Kona

Directive reference

Quick lookup for Crema syntax. For explanations and full examples, follow the “Guide” links.

Syntax Purpose Guide
{{ expr }} Escaped output Rendering
{!! expr !!} Raw HTML output Rendering
@@ Literal @ Rendering
{{-- … --}} Comment (stripped) Rendering
Directive Closer / notes Guide
@extends('layout') Child declares parent layout Layouts
@section('name', 'text') Inline section Layouts
@section('name') Block section @endsection or @show
@endsection End block section (store raw) Layouts
@show End section and expand immediately Layouts
@yield('name') Print section Optional default: @yield('n', 'default')
@parent Insert parent section buffer Inside a child @section
@hasSection('name') Body if section defined Closes with @endif
@sectionMissing('name') Body if section missing Closes with @endif
Directive Closer Guide
@push('name') @endpush Stacks
@prepend('name') @endprepend Stacks
@stack('name') — Stacks
Directive Notes Guide
@include('name') Required; throws if missing Includes
@includeIf('name') Skip if missing Includes
@includeWhen(expr, 'name') When truthy Includes
@includeUnless(expr, 'name') When not truthy Includes
@includeFirst(['a', 'b']) First resolvable name Includes
@once @endonce — once per render Includes
@verbatim @endverbatim — no processing Includes
Directive Closer Guide
@if(expr) @endif (@elseif / @else optional) Control structures
@unless(expr) @endunless Control structures
@isset(name) @endisset Control structures
@empty(expr) @endempty Control structures
Directive Closer Notes Guide
@foreach(items as item) @endforeach Also as key => value Control structures
@each(items as item) @endeach Alias of foreach Control structures
@for(…) @endfor Collection, i in a..b, or C-style Control structures
@forelse(items as item) @endforelse Requires @empty branch Control structures
@while(expr) @endwhile Cap 10 000; injects loop Control structures

index, iteration, first, last, count, remaining, even, odd, depth, parent — see Loop metadata.

Directive Closer Data keys Guide
@auth @endauth __authenticated, auth_user, user Control structures
@guest @endguest Same as @auth (inverted) Control structures
@can('ability') @endcan __abilities, can Control structures
@cannot('ability') @endcannot Same as @can (inverted) Control structures
Directive Notes Guide
@switch(expr) Opens switch @endswitch
@case(expr) Stringified equality Control structures
@break Stop active arm Control structures
@default When no case matched Control structures
Syntax Purpose Guide
@component('name')…@endcomponent Render a view as a component Components
@slot('name')…@endslot Named slot inside @component Components
<x-name>…</x-name> Render components.name Components
<x-name /> Empty default slot Components
<x-slot name="n">…</x-slot> Named slot for <x-*> or prefixed tags Components
<x-slot:n>…</x-slot:n> Colon-name form Components
<prefix:slot name="n">… Named slot for extension tags Components

Inside the component view: {{ slot }} (default) and {{ name }} for each named slot.

Directive Purpose Guide
@csrf Hidden _token input Forms
@method('VERB') Hidden _method input Forms
@error('field') @enderror when errors has field Forms
@asset('path') Public asset URL Rendering
@json($expr) JSON encode Rendering
@lang('key') Translation Optional replace map
@vite('entry') Script/link tags under /build List form supported

Apps and packages can register more syntax on CremaEngine:

API Shape
directive(name) { … } @name / @name(args)
blockDirective(name) { … } @name…@endname
tag(prefix) { … } <prefix:name>…

Brew uses these for @brew and <brew:…>. See Brew (full guides on the Brew docs site).