Skip to content

Commit 9c54cc5

Browse files
author
Illia Sakovich
committed
custom blade directive small changes
1 parent 82b2df4 commit 9c54cc5

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

config/shared-data.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,16 @@
3434
],
3535

3636
/*
37-
* Blade directive name.
38-
*
39-
* By default the Blade directive named 'shared'.
40-
*
41-
* It means that the shared data rendering will be available in view files via `@shared`
37+
* The settings for the Blade directive.
4238
*/
43-
'blade_directive' => 'shared',
39+
'blade_directive' => [
40+
/*
41+
* Blade directive name.
42+
*
43+
* By default the Blade directive named 'shared'.
44+
*
45+
* It means that the shared data rendering will be available in view files via `@shared`.
46+
*/
47+
'name' => 'shared',
48+
],
4449
];

src/Providers/SharedDataServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function register()
3838
});
3939

4040
$this->app->extend('blade.compiler', function (BladeCompiler $bladeCompiler) {
41-
$bladeCompiler->directive($this->app['config']['shared-data']['blade_directive'], function () {
41+
$bladeCompiler->directive($this->app['config']['shared-data.blade_directive.name'], function () {
4242
return '<?php echo app(\\'.SharedData::class.'::class)->render(); ?>';
4343
});
4444

tests/SharedDataTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,15 +305,13 @@ public function testBladeDirective()
305305
/**
306306
* @depends testBladeDirective
307307
*/
308-
public function testBladeDirectiveCustom()
308+
public function testBladeDirectiveWithCustomName()
309309
{
310-
$this->app->make('config')->set('shared-data.blade_directive', 'shared_custom');
311-
312-
$this->app->register(SharedDataServiceProvider::class);
310+
$this->app['config']['shared-data.blade_directive.name'] = 'shared_custom';
313311

314312
$this->assertEquals(
315313
shared()->render(),
316-
view('shared-custom')->render()
314+
view('shared_custom')->render()
317315
);
318316
}
319317
}

0 commit comments

Comments
 (0)