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][Docs] Fix outerblock markup example #2235

Merged
merged 1 commit into from
Oct 5, 2024

Conversation

tobiasberge
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
Issues See below...
License MIT

I was following the guide for nested UX components and inheritance. Really cool stuff. 👍

Inheritance & Forwarding "Outer Blocks"

I was confused about this code example that re-uses the alert component and "passes through" the content text from the SuccessAlert component usage:

{# templates/components/SuccessAlert.html.twig #}
<twig:Alert type="success">
{% component Alert with {type: 'success'} %}
    {{ block(outerBlocks.content) }}
</twig:Alert>

Is it really supposed to be two nested alert components? Because this throws an error because of the missing {% endcomponent %} tag.

Should it be either this...

{# templates/components/SuccessAlert.html.twig #}
<twig:Alert type="success">
    {{ block(outerBlocks.content) }}
</twig:Alert>

or this syntax?

{# templates/components/SuccessAlert.html.twig #}
{% component Alert with {type: 'success'} %}
    {{ block(outerBlocks.content) }}
{% endcomponent %}

@carsonbot carsonbot added Bug Bug Fix Status: Needs Review Needs to be reviewed labels Oct 4, 2024
@tobiasberge tobiasberge changed the title Change component usage inside inheritance example Docs: Change component usage inside inheritance example Oct 4, 2024
Copy link
Member

@smnandre smnandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @tobiasberge!

@carsonbot carsonbot added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Review Needs to be reviewed labels Oct 5, 2024
@smnandre
Copy link
Member

smnandre commented Oct 5, 2024

Is it really supposed to be two nested alert components?

With your fix it's more logic :)

@smnandre smnandre added docs Improvements or additions to documentation TwigComponent and removed Bug Bug Fix labels Oct 5, 2024
@smnandre smnandre changed the title Docs: Change component usage inside inheritance example [TwigComponent][Docs] Fix outerblock markup example Oct 5, 2024
@Kocal
Copy link
Member

Kocal commented Oct 5, 2024

Thank you @tobiasberge.

@Kocal Kocal merged commit 5944258 into symfony:2.x Oct 5, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation Status: Reviewed Has been reviewed by a maintainer TwigComponent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants