forked from roots/sage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThemeServiceProvider.php
48 lines (40 loc) · 1.2 KB
/
ThemeServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Blade;
use Roots\Acorn\Sage\SageServiceProvider;
class ThemeServiceProvider extends SageServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
parent::register();
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
parent::boot();
if ($this->app->bound('blade.compiler')) {
$this->registerDirectives();
}
}
protected function registerDirectives(): void
{
Blade::directive('parseblocks', static fn () => "<?php if (\Roots\use_fse()): ob_start(); ?>");
Blade::directive('endparseblocks', static fn () => '<?php $block_content = ob_get_clean(); echo do_blocks($block_content); endif; ?>');
Blade::directive(
'blocktemplate',
static fn ($block) => $block !== ''
? "<?php if (\Roots\use_fse()): block_template_part({$block}); else: ?>"
: "<?php if (!\Roots\use_fse()): ?>"
);
Blade::directive('endblocktemplate', static fn () => '<?php endif; ?>');
}
}