diff --git a/README.md b/README.md index 235584f..c786791 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" }} + + + + +``` + ### @script and @assets Antlers versions of [@script](https://livewire.laravel.com/docs/javascript#executing-scripts) and [@assets](https://livewire.laravel.com/docs/javascript#loading-assets) are provided: diff --git a/src/Tags/Livewire.php b/src/Tags/Livewire.php index b8a2906..5aee3d7 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.