stonehilt / blade
StoneHilt's blade directives and other view helpers
Requires
- php: ^8.2
- ext-json: *
- laravel/framework: ~10
- symfony/http-foundation: ^6.4
Requires (Dev)
- avastechnology/iolaus: *
- fakerphp/faker: ^1.9.1
- phpunit/phpunit: ~10.0
This package is auto-updated.
Last update: 2025-04-29 01:36:22 UTC
README
Adds blade directives that have not been integrated into the framework.
Overtime these directives may be deprecated and integrated into the core Laravel framework.
Installation
Include this library:
~ composer require stonehilt/blade
The StoneHiltBladeServiceProvider
will automatically be loaded and the new directives will be available.
This overrides the creation of the Factory object with a custom version.
If the project has extended the Factory object, please change the extension to use StoneHilt\Blade\View\Factory
.
Directives
form
Generate an HTML form element. The CSRF token is automatically included when the method if "POST". Automatically mocks "PUT", "PATCH" and "DELETE" requests via a hidden "_method" input.
Signature: @form(array $options)
$options
is an associative array of attributes. Special Attributes:- method Form method attribute (required if route not set)
- action Form action attribute (required if route not set)
- route Use a named route to determine Form method and action attributes All other values are mapped directly to the HTML attribute.
Example:
@form(['method' => 'POST', 'action' => '/page/2', 'class' => 'class name'])
<!-- form contents -->
@endform
Signature: @form(string $method, string $action)
$method
Form method$action
Form action
Example:
@form('POST', '/page/2')
<!-- form contents -->
@endform
inherit
Inherit properties from the parent component into a child's component view. This is useful when the child component needs to know the id or other key attributes of the parent component.
Signature: @inherit(array $mapping)
$mapping
is an associative array of parent component field to local alias
Example:
@inherit(['id' => 'parentId'])
{{ $parentId }}
route
Return the route path based upon the name.
Signature: @route(string $name, array $parameters = [])
$name
Route name$parameters
Parameters for the route (if applicable)
Example:
@route('post.update', ['page' => 2])