tempest-framework
tempest-framework copied to clipboard
Dynamic components throw warnings in a foreach loop
Tempest version
2.3.3
PHP version
8.4
Operating system
macOS
Description
I am trying to render a component dynamically in a loop. Outside of a loop, it works fine. But when I try to render the component in a loop, based on a variable which lives in the scope of that loop, I get a warning that the variable I am using is not defined. I tried several ways, but I can't get rid of the warning.
Maybe I'm overlooking something obvious, but I suspect it might be a bug.
Steps to reproduce
Create a controller method which returns this:
return view('home.view.php', components: [
'x-component-1',
'x-component-2'
]);
You also need two empty components, x-component-1.view.php and x-component-2.view.php. And a view that looks like this:
<!-- Works fine -->
<x-component :is="$components[0]" />
<x-template :foreach="$components as $component">
<!-- Works fine too -->
{{ lw($component) }}
<!-- Warning: Undefined variable $component -->
<x-component :is="$component" />
</x-template>