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

Question: Transform HTML like Tag to TWIG tag #3870

Closed
AndreRudolph opened this issue Aug 11, 2023 · 2 comments
Closed

Question: Transform HTML like Tag to TWIG tag #3870

AndreRudolph opened this issue Aug 11, 2023 · 2 comments

Comments

@AndreRudolph
Copy link

AndreRudolph commented Aug 11, 2023

I am looking for a hook in twig engine with that I can transform something like

<foo bar="baz" />

into

{{ func("foo", { bar: "baz" } ) }}

I am not sure how I can achieve this and where in the compilation process this must happen. Is this a NodeVisitor or rather responsibility of a TokenParser? Or something completely else? Should this maybe happen at FileLoader / Cache level and with regex replacing? Unfortunately the twig documentation does not cover such a topic in depth.

Looking forward for any advices and tips, thank you.

PS: I know I could just simply put the second snippet in the template but I want to provide the first snippet as some kind of nice-to-have option that will be converted to the second snippet.

@AndreRudolph AndreRudolph changed the title Transform HTML Tag to twig tag Question: Transform HTML like Tag to TWIG tag Aug 11, 2023
@kbond
Copy link
Contributor

kbond commented Sep 8, 2023

Hey @AndreRudolph, you can take a look at what we did in ux-twig-components: https://symfony.com/bundles/ux-twig-component/current/index.html#component-html-syntax

@fabpot
Copy link
Contributor

fabpot commented Dec 15, 2023

Closing in favor of #3867

@fabpot fabpot closed this as completed Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants