Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TwigComponent] Passing HTML to Components Via Blocks Is Not Possible With Variable Component Name #1852

Open
kickingRaccoon opened this issue May 16, 2024 · 2 comments

Comments

@kickingRaccoon
Copy link

Hello Teams & Thanks for the works on Twig Components (Amazing !!!)

I m try to do a library for my components and i need to call them dynamicaly:

{% set component = 'My:Component' %°} {# I don t really do that in my template ... #}
{{ component(component) }}

and it works great !!!

but for particular component i need to set some inner HTML:

{% set component = 'My:Component' %°}
{% component(component)  with my_args%}
    <div>...</div>
{% endcomponent %}

and then 💥 :

Error rendering "component" component: Unknown component "component". And no matching anonymous component template was found.

It seems Symfony\UX\TwigComponent\Twig\ComponentTokenParser::componentName() does not parse the variable but simply render the name of the NameExpression (there's no compiling of the NameExpression ...)

There is another way to do that or it 's simply a bug or it's intentional ?

Thank you for the response and for all

@smnandre
Copy link
Collaborator

Embedded component names need to be resolved before runtime, so it wont work in your second example indeed.

@kickingRaccoon
Copy link
Author

Thanks
I will try another way ... 😢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants