Skip to content

Commit

Permalink
Merge pull request #708 from tighten/fix-dynamic-components
Browse files Browse the repository at this point in the history
Fix dynamic components
  • Loading branch information
damiani authored Jun 27, 2024
2 parents 114ed16 + 6850835 commit f47335a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Providers/ViewServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace TightenCo\Jigsaw\Providers;

use Illuminate\View\DynamicComponent;
use Illuminate\View\Engines\CompilerEngine;
use Illuminate\View\Engines\EngineResolver;
use Illuminate\View\Engines\FileEngine;
Expand All @@ -16,6 +15,7 @@
use TightenCo\Jigsaw\Support\ServiceProvider;
use TightenCo\Jigsaw\View\BladeCompiler;
use TightenCo\Jigsaw\View\BladeMarkdownEngine;
use TightenCo\Jigsaw\View\DynamicComponent;
use TightenCo\Jigsaw\View\MarkdownEngine;
use TightenCo\Jigsaw\View\ViewRenderer;

Expand Down
22 changes: 22 additions & 0 deletions src/View/DynamicComponent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace TightenCo\Jigsaw\View;

use Illuminate\Container\Container;
use Illuminate\View\DynamicComponent as BaseDynamnicComponent;

class DynamicComponent extends BaseDynamnicComponent
{
protected function compiler()
{
if (! static::$compiler) {
static::$compiler = new ComponentTagCompiler(
Container::getInstance()->make('blade.compiler')->getClassComponentAliases(),
Container::getInstance()->make('blade.compiler')->getClassComponentNamespaces(),
Container::getInstance()->make('blade.compiler')
);
}

return static::$compiler;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="alert alert-danger">
<h3>This is the component</h3>
<h4>Named title slot: {{ $title }}</h4>
<hr>
{{ $slot }}
<hr>
</div>
6 changes: 6 additions & 0 deletions tests/snapshots/dynamic-component/source/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@php
$dynamic = 'alert';
@endphp
<x-dynamic-component :component="$dynamic" title="Title">
Slot
</x-dynamic-component>
7 changes: 7 additions & 0 deletions tests/snapshots/dynamic-component_snapshot/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="alert alert-danger">
<h3>This is the component</h3>
<h4>Named title slot: Title</h4>
<hr>
Slot
<hr>
</div>

0 comments on commit f47335a

Please sign in to comment.