From ca6bcd24ee38110f1fe776c77672c172b8f8ebb8 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Fri, 6 Sep 2024 13:59:35 +0100 Subject: [PATCH 1/2] Allow for dynamic component names --- src/Tags/Livewire.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Tags/Livewire.php b/src/Tags/Livewire.php index 57f0c52..d1a3c4f 100644 --- a/src/Tags/Livewire.php +++ b/src/Tags/Livewire.php @@ -15,6 +15,16 @@ public function wildcard($expression): string { return \Livewire\Livewire::mount($expression, $this->params->except('key')->toArray(), $this->params->only('key')->first()); } + + /** + * This will load your Livewire component in the Antlers view + * + * {{ livewire:component name="my-component" }} + */ + public function component(): string + { + return $this->wildcard($this->params->pull('name')); + } /** * Sharing State Between Livewire And Alpine via entangle. From bec149d49355f62f1853275672c0a875ad51c1c2 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Fri, 6 Sep 2024 14:54:30 +0100 Subject: [PATCH 2/2] docs --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index fce2a66..e5f1f69 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,18 @@ To include your Livewire component: ``` +if you want to include a component from a dynamic variable you can use the `livewire:component` tag: + +```html + + + {{ livewire:component :name="variable" }} + + + + +``` + ### Blade or Antlers? Both! If creating a Livewire component, you need to render a template file