Download the PHP package edalzell/blade-directives without Composer
On this page you can find all versions of the php package edalzell/blade-directives. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download edalzell/blade-directives
More information about edalzell/blade-directives
Files in edalzell/blade-directives
Package blade-directives
Short Description Blade directives that work w/ Statamic
License MIT
Informations about the package blade-directives
Blade Directives
This package provides custom directives so you can easily access Statamic data in your Blade templates.
ARCHIVED
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.
Requirements
- PHP 7.4+
- Statamic v3.2
Installation
You can install this package via composer using:
The package will automatically register itself.
Usage
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.
Antlers
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.
We do this by using the Antlers Facade and its parse method.
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,
But now if we instead remove the single quotes from foo, then we will need to provide the context of what foo is.
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.
You can also use @php blocks to define the content and or 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()
Assets
Breadcrumbs
You can use the same parameters as the nav:breadcrumbs
tag.
Collection
Use the same params as the {{ collection }}
tag
Collection Pagination
Data
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).
Entry
Gets all the data in an entry. In the example below the data is a replicator, so you have to walk through the sets.
Forms
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 Fields
Loops over the fields for a form.
Glide
Generates the glide image.
Globals
Nav
You can use the same parameters as the nav
tag.
Site
Taxonomy
Use the same params as the {{ taxonomy }}
tag
Testing
Run the tests with:
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.
All versions of blade-directives with dependencies
laravel/framework Version ^7.30.3 || ^8.24 || ^9.0
statamic/cms Version ^3.0