Skip to content
This repository was archived by the owner on Jan 27, 2025. It is now read-only.

Commit ad7726f

Browse files
Merge pull request #69 from ryanmitchell/feature/allow-for-dynamic-component-names
Allow for dynamic component names
2 parents be2b8b1 + 3c649b6 commit ad7726f

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ To include your Livewire component:
108108
</body>
109109
```
110110
111+
if you want to include a component from a dynamic variable you can use the `livewire:component` tag:
112+
113+
```html
114+
<body>
115+
<!-- If using Antlers -->
116+
{{ livewire:component :name="variable" }}
117+
118+
<!-- If using Blade -->
119+
<livewire:component name="$variable" />
120+
</body>
121+
```
122+
111123
### @script and @assets
112124
Antlers versions of [@script](https://livewire.laravel.com/docs/javascript#executing-scripts) and [@assets](https://livewire.laravel.com/docs/javascript#loading-assets) are provided:
113125

src/Tags/Livewire.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ public function wildcard($expression): string
1515
{
1616
return \Livewire\Livewire::mount($expression, $this->params->except('key')->toArray(), $this->params->only('key')->first());
1717
}
18+
19+
/**
20+
* This will load your Livewire component in the Antlers view
21+
*
22+
* {{ livewire:component name="my-component" }}
23+
*/
24+
public function component(): string
25+
{
26+
return $this->wildcard($this->params->pull('name'));
27+
}
1828

1929
/**
2030
* Sharing State Between Livewire And Alpine via entangle.

0 commit comments

Comments
 (0)