Skip to content

Conversation

mikadamczyk
Copy link
Contributor

🎫 Issue IBX-XXXXX

Description:

We cannot move the “has content” check for the content block into the PHP side of a Symfony UX Twig Component, because the component class has no access to the rendered output of Twig blocks/slots. Blocks are resolved only during template rendering, so from PHP, you cannot reliably know if the content slot is empty or not.

We will keep the check in Twig, but avoid repeated block('content') calls by buffering the block once into a variable.

{% set _content %}{% block content %}{% endblock %}{% endset %}
{% set has_content = _content|striptags|trim is not empty %}

This way _content can be reused wherever needed, and has_content gives a clean boolean to control conditional rendering. If further centralization is desired, a small Twig filter/test or a helper method can process _content, but the capture of the block itself must remain in Twig.

For QA:

Documentation:

@mikadamczyk mikadamczyk requested review from a team and GrabowskiM October 2, 2025 12:54
@mikadamczyk mikadamczyk self-assigned this Oct 2, 2025
Base automatically changed from phpstan-fix to main October 6, 2025 09:07
@mikadamczyk mikadamczyk merged commit 7c3880f into main Oct 13, 2025
4 checks passed
@mikadamczyk mikadamczyk deleted the has-content-improvements branch October 13, 2025 07:36
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.

4 participants