Skip to content

[TwigComponents] Fixing inconsistency with how {% component rendered vs {{ component() #1247

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

Merged
merged 1 commit into from
Nov 6, 2023

Conversation

weaverryan
Copy link
Member

Q A
Bug fix? yes
New feature? no
Issues Fix #1205 (?) and maybe others?
License MIT

tl;dr {% component was rendered slightly differently than {{ component. Additionally, for {% component, the template was determined too early, which didn't allow for the template to be overridden via an event.

Longer Explanation

This cleans up ComponentTokenParser, removing some unnecessary parts. We now always set the "embedded" component parent to a magic __parent__ variable. This allows us to delay the determination of the component template until runtime, after the PreRenderEvent has been called.

TODO:

Cheers!

@smnandre
Copy link
Member

smnandre commented Nov 4, 2023

Just tried, both "TwigComponent should pass" tests are OK

@smnandre
Copy link
Member

smnandre commented Nov 4, 2023

DebugCommand seems OK after a couple of tests

@weaverryan weaverryan force-pushed the twig-components-improved-embed branch from 06f6b07 to df6388e Compare November 6, 2023 18:00
@weaverryan weaverryan merged commit 643382b into symfony:2.x Nov 6, 2023
@weaverryan
Copy link
Member Author

@smnandre would you mind rebasing your 2 PR's? I'd like to verify they pass - then we can merge those in

@weaverryan weaverryan deleted the twig-components-improved-embed branch November 6, 2023 18:01
@smnandre
Copy link
Member

smnandre commented Nov 6, 2023

@smnandre would you mind rebasing your 2 PR's? I'd like to verify they pass - then we can merge those in

Will do in 2/3 hours

smnandre added a commit to smnandre/ux that referenced this pull request Apr 23, 2024
I believe this modification fix issue symfony#1754

**Original problem**

If you render a template @Acme/dashboard.html.twig, embedded Components (live or twig) referenced wrong template (dashboard.html.twig here), making LiveComponent impossible to rerender (this file beeing not referenced in the TemplateMap).

This behaviour was introduced in symfony#1082 (and worked then). But i'm convinced all the work/changes made by Ryan to fix the embed bug (symfony#1247 and related) made this obselete (and in this particular situation even originates a bug)

All tests are green, and i'd like to test it more heavily... but before that : do you think this is a bug fix or is there some kind of BC break here?
smnandre added a commit to smnandre/ux that referenced this pull request Apr 24, 2024
I believe this modification fix issue symfony#1754

**Original problem**

If you render a template @Acme/dashboard.html.twig, embedded Components (live or twig) referenced wrong template (dashboard.html.twig here), making LiveComponent impossible to rerender (this file beeing not referenced in the TemplateMap).

This behaviour was introduced in symfony#1082 (and worked then). But i'm convinced all the work/changes made by Ryan to fix the embed bug (symfony#1247 and related) made this obselete (and in this particular situation even originates a bug)

All tests are green, and i'd like to test it more heavily... but before that : do you think this is a bug fix or is there some kind of BC break here?
kbond added a commit that referenced this pull request Apr 25, 2024
This PR was squashed before being merged into the 2.x branch.

Discussion
----------

[TwigComponent] Fix LiveComponent namespace mapping

I believe this modification fix #1754

**Original problem**

If you render a template `@Acme`/dashboard.html.twig, embedded Components (live or twig) referenced wrong template (dashboard.html.twig here), making LiveComponent impossible to rerender (this file beeing not referenced in the TemplateMap).

This behaviour was introduced in #1082 (and worked then). But i'm convinced all the work/changes made by Ryan to fix the embed bug (#1247 and related) made this obselete (and in this particular situation even originates a bug)

All tests are green, and i'd like to test it more heavily... but before that : do you think this is a bug fix or is there some kind of BC break here?

Commits
-------

bb76055 [TwigComponent] Fix LiveComponent namespace mapping
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to find custom template for UX components with <twig:component> syntax
2 participants