Skip to content

Commit 84f18f8

Browse files
Register directives only when blade is actually needed (#395)
1 parent 4056517 commit 84f18f8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/ServiceProvider.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Illuminate\Foundation\Testing\TestResponse as LegacyTestResponse;
66
use Illuminate\Http\Request;
77
use Illuminate\Routing\Router;
8-
use Illuminate\Support\Facades\Blade;
98
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
109
use Illuminate\Testing\TestResponse;
1110
use Illuminate\View\FileViewFinder;
@@ -27,6 +26,7 @@ public function register(): void
2726
'inertia'
2827
);
2928

29+
$this->registerBladeDirectives();
3030
$this->registerRequestMacro();
3131
$this->registerRouterMacro();
3232
$this->registerTestingMacros();
@@ -42,7 +42,6 @@ public function register(): void
4242

4343
public function boot(): void
4444
{
45-
$this->registerBladeDirectives();
4645
$this->registerConsoleCommands();
4746

4847
$this->publishes([
@@ -52,8 +51,10 @@ public function boot(): void
5251

5352
protected function registerBladeDirectives(): void
5453
{
55-
Blade::directive('inertia', [Directive::class, 'compile']);
56-
Blade::directive('inertiaHead', [Directive::class, 'compileHead']);
54+
$this->callAfterResolving('blade.compiler', function ($blade) {
55+
$blade->directive('inertia', [Directive::class, 'compile']);
56+
$blade->directive('inertiaHead', [Directive::class, 'compileHead']);
57+
});
5758
}
5859

5960
protected function registerConsoleCommands(): void

0 commit comments

Comments
 (0)