m2collective/laravel-blade-directive
Composer 安装命令:
composer require m2collective/laravel-blade-directive
包简介
README 文档
README
This package simplifies and systematizes the creation and registration of user directives.
Installation
You can install the package via composer:
composer require m2collective/laravel-blade-directive
The package will automatically register itself.
Usage
By installing the package, you can create and register directives in a simpler and more intuitive way.
Default Directive
Creating a simple directive for displaying or formatting incoming arguments.
use M2Collective\BladeDirective\DefaultBladeDirective; final class Example implements DefaultBladeDirective { /** * @return string */ public function tag(): string { return 'example'; } /** * @param mixed $expression * @return string */ public function handler(mixed $expression) : string { //... } }
Logical Directive
Creating a logical directive that satisfies certain conditions.
use M2Collective\BladeDirective\LogicalBladeDirective; final class Example implements DefaultBladeDirective { /** * @return string */ public function openingTag(): string { return 'example'; } /** * @param mixed $expression * @return string */ public function openingHandler(mixed $expression) : string { //... } /** * @return string */ public function elseTag(): string { return 'elseExample'; } /** * @param mixed $expression * @return string */ public function elseHandler(mixed $expression) : string { //... } /** * @return string */ public function closingTag(): string { return 'endExample'; } /** * @param mixed $expression * @return string */ public function closingHandler(mixed $expression) : string { //... } }
Registering Directives
New directives are registered through the service provider.
use M2Collective\BladeDirective\Concerns\RegisterBladeDirectives; final class ExampleServiceProvider extends ServiceProvider { use RegisterBladeDirectives; /** * @return void */ public function boot(): void { $this->registerBladeDirective( new ExampleDirective() ); // or $this->registerBladeDirectives([ new ExampleDirective(), //... ]); } }
License
The MIT License (MIT). Please see the License file for more information.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-17