Skip to content

Commit 1bee870

Browse files
authored
Merge pull request #29 from mabdullahsari/optimize-blade-directives
Use container events
2 parents 09abaa5 + dc24d53 commit 1bee870

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/LaravelHtmxServiceProvider.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@
66

77
use Illuminate\Support\Facades\View;
88
use Illuminate\Support\ServiceProvider;
9+
use Illuminate\View\Compilers\BladeCompiler;
910
use Mauricius\LaravelHtmx\Http\HtmxRequest;
1011
use Mauricius\LaravelHtmx\View\BladeFragment;
1112

1213
class LaravelHtmxServiceProvider extends ServiceProvider
1314
{
1415
public function boot(): void
1516
{
16-
$this->app['blade.compiler']->directive('fragment', fn () => '');
17-
18-
$this->app['blade.compiler']->directive('endfragment', fn () => '');
17+
$this->callAfterResolving('blade.compiler', static function (BladeCompiler $blade) {
18+
$blade->directive('endfragment', static fn () => '');
19+
$blade->directive('fragment', static fn () => '');
20+
});
1921

2022
$this->app->bind(HtmxRequest::class, fn ($container) => HtmxRequest::createFrom($container['request']));
2123

0 commit comments

Comments
 (0)