Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dynamic components #708

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading