Dynamic component name Hi,
Is there a way to display component in blade file using variable name?
Im trying to do something like this:
<x-{{ $component_name }} />
but that doesn't seems to work.
those <x- tags don't really exist. The blade compiler turns them into regular html snippets. So to do what you are asking, I think you would need a blade pre-compiler that took your view file and converted it to blade file.
Happy to be corrected by others
I see. It would be really grat to have something like vuejs has.
<x-component is="component-name" />
Thanks for the suggestrion @snapey . I created inline component where i precompile
the string and then compile it again ;)
$precompiled = resolve('blade.compiler')->compileString('<div>
<x-' . $this->is . ' />
</div>');
return resolve('blade.compiler')->compileString($precompiled);
Please sign in or create an account to participate in this conversation.