This package is abandoned and no longer maintained. No replacement package was suggested.

Blade directives that work w/ Statamic

Fund package maintenance!

Installs: 54 974

Dependents: 1

Suggesters: 0

Security: 0

Stars: 53

Watchers: 2

Forks: 23

v3.7 2022-03-19 22:12 UTC


MIT Licensed

This package provides custom directives so you can easily access Statamic data in your Blade templates.


Note that with the release of Statamic 3.3, this addon is no longer needed. Please update to 3.3 and use the native Statamic::tag(...) functionality. If you need any changes, please fork.


  • PHP 7.4+
  • Statamic v3.2


You can install this package via composer using:

composer require edalzell/blade-directives

The package will automatically register itself.


Automatic augmentation of Statamic values

If you want values to be augmented automatically in your Blade views, you can replace the

Illuminate\View\ViewServiceProvider::class in the providers of your config/app.php with \Edalzell\Blade\Augmentation\AugmentationViewServiceProvider

This will replace all instances of \Statamic\Fields\Value by their augmented values.


If tag(), modify() or any of the below directives aren't achieving the desired outcome, it is possible to try the Antlers directive to render Antlers within Blade.

@antlers($str, $variables = [])

We do this by using the Antlers Facade and its parse method.

\Statamic\Facades\Antlers::parse($str, /* $variables = [] or collect(get_defined_vars())->except('__data', '__path')->toArray() */)

There are some things to note however, for these examples we will describe $str as the content or string that you wish to have Antlers parse into Html, while $variables is the context or data that will be passed to Antlers and is used to map variables and data to Antlers, The context will automatically be added to the Antlers::parse call, however if you define the second parameter $variables then the default context will be ignored and your supplied context will act as an override.

An example of this would be if we passed $str into our view,

view('home', ['str' => "{{ 'foo' }}"]);
This will output foo.

But now if we instead remove the single quotes from foo, then we will need to provide the context of what foo is.

view('home', [
    'str' => "{{ foo }}",
    'variables' = ['foo' => 'bar']
This will output the value of foo that we assigned in the context, which would output bar.
@antlers($str, $variables)

It is also possible to use the directive inline. If passing everything inline, then the Antlers content will need to have @ added to its curly braces. quotes will need to be escaped too.

This will output testing.
@antlers('@{{ test }}', ['test' => 'testing'])

You can also use @php blocks to define the content and or context.

    $content = '{{ test | ucfirst }}';
    $context = ['test' => 'testing'];

This will output Testing.
@antlers($content, $context)

This directive can be used in a bunch of different ways, let your imagination run wild! All you need to do is provide the content and then any context that it might need, how you get/set or provide those doesn't really matter that much.

The default context can be obtained with the following code collect(get_defined_vars())->except('__data', '__path')->toArray()


    URl: {{ $asset['url'] }}
    Permalink: {{ $asset['permalink'] }}
    Alt: {{ $asset['alt'] }}
    ...other fields



You can use the same parameters as the nav:breadcrumbs tag.

@breadcrumbs(['include_home' => false, 'reverse' => true])


Use the same params as the {{ collection }} tag

@collection('pages', ['title:is' => 'My Title', 'author:is' => 'Erin', 'limit' => 3, 'sort' => 'title:desc'])\
        <p>There are no results</p>
        {{ $entry['title'] }}

Collection Pagination

@collection('the_collection', ['limit' => 2, 'paginate' => true])
    @foreach($entry['entries'] as $entry)
            Title: {{ $title }}


Use this when you have Statamic data but it's a Value object. This will return a keyed array with all the fields as string/ints/arrays (recursively).

    {{ $fieldYouWant }}


Gets all the data in an entry. In the example below the data is a replicator, so you have to walk through the sets.

@entry('the_collection_handle', 'entry-slug')
    @foreach($replicator as $set)
        <p>Type is {{ $set['type'] }}</p>
        @include("partials/{$set['type']}", $set)


You can pass in the same parameters that {{ form:create }} supports. Any other parameters will be added to the <form> tag as attributes.

To access the errors, use standard Blade errors but pass in the proper error bag, which is form.your-form-handle.

@form('contact_us', ['redirect'=> '/', 'error_redirect' => '', 'allow_request_redirect' => false, 'id' => 'form-id', 'class' => 'foo'])
Email: <input type="text" name="email" />
@error('email', 'form.contact_us')
    <div>{{ $message }}</div>
<button>Contact Us</button>

Form Fields

Loops over the fields for a form.

<label>{{ $field['display'] }}</label>
<input type="{{ $field['type'] }}" name="{{ $field['handle'] }}" placeholder="{{ $field['placeholder'] ?? '' }}" />


Generates the glide image.

@glide('/assets/IMG_1325.jpeg', ['width' => 100])
    <p>URL is {{ $url }}</p>
    <img src="{{ $url }}">
    <p>Width is {{ $width }}</p>
    <p>Hight is {{ $height }}</p>


    {{ $set_variable }}

@globalset('footer', 'set_variable')


    {{ $item['title'] }}

You can use the same parameters as the nav tag.

@nav('collection::pages', ['from' => '/', 'show_unpublished' => true, 'include_home' => true])
    {{ $item['title'] }}


    {{ $short_locale }}


Use the same params as the {{ taxonomy }} tag

@taxonomy('tags', ['limit' => 6, 'sort' => 'entries_count:desc'])
    <p>Title is {{ $term['title'] }}</p>


Run the tests with:



Please see CHANGELOG for more information what has changed recently.


Please see CONTRIBUTING for details.


If you discover any security related issues, please email addon-security@silentz.co instead of using the issue tracker.


The MIT License (MIT). Please see License File for more information.