eslym / laravel-blade-utils
Some fix and utilities for blade
1.1.0
2021-02-20 01:40 UTC
Requires
- php: >= 7.1
- ext-json: *
- illuminate/support: >=5.6 <9.0
- illuminate/view: >=5.6 <9.0
README
Some blade utilities including fix for @json
directive and improvement on @each
directive
Installation
composer require eslym/laravel-blade-utils ^1.0
Configuration
Laravel
Let package discovery to do its job.
Lumen
# bootstrap/app.php ... $app->register(Eslym\BladeUtils\Providers\BladeUtilServiceProvider::class); ...
Features
Fix for @json
directive
This fix made @json
directive supports more complex syntax.
@json([$val1, $val2, $val3, $val4])
will be compiled to <?php echo json_encode([$val1, $val2, $val3, $val4], 15, 512); ?>
instead of <?php echo json_encode([$val1, $val2, $val3); ?>
by original blade directive.
Better @each
directive
@each
directive will now include with variables in current scope.
@js
and @css
directives
Syntax:
@js($uri, [$sri], [$crossorigin]) @css($uri, [$sri], [$crossorigin])
PhpStorm
If you are using phpstorm, please enable custom blade settings and add these entries into .idea/blade.xml
for type hint.
<directives> ... <data directive="@js" injection="true" prefix="<?php __ide_blade_helper::js(" suffix="); ?>"/> <data directive="@css" injection="true" prefix="<?php __ide_blade_helper::css(" suffix="); ?>"/> <data directive="@img" injection="true" prefix="<?php __ide_blade_helper::img(" suffix="); ?>"/> <data directive="@iif" injection="true" prefix="<?php __ide_blade_helper::iif(" suffix="); ?>"/> <data directive="@meta" injection="true" prefix="<?php __ide_blade_helper::meta(" suffix="); ?>"/> <data directive="@nameMeta" injection="true" prefix="<?php __ide_blade_helper::nameMeta(" suffix="); ?>"/> <data directive="@propMeta" injection="true" prefix="<?php __ide_blade_helper::propMeta(" suffix="); ?>"/> <data directive="@itemMeta" injection="true" prefix="<?php __ide_blade_helper::itemMeta(" suffix="); ?>"/> </directives>