Skip to content

Conversation

@fritzmg
Copy link
Contributor

@fritzmg fritzmg commented Apr 26, 2025

Since this was already asked a few times in the community.

Copy link
Member

@zoglo zoglo left a comment

Choose a reason for hiding this comment

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

Looks good to me, might be a bit confusing with the trailing and leading whitespace trimming but it's an example that could be copied.

I guess using parent() is due to modifications from other bundles since there is no content inside it in the original template?

@fritzmg
Copy link
Contributor Author

fritzmg commented Apr 26, 2025

might be a bit confusing with the trailing and leading whitespace trimming

Confusing in what way? Without it your (dev) output will be

<h2         class="foobar"
>

I guess using parent() is due to modifications from other bundles since there is no content inside it in the original template?

There is content inside the block: https://github.com/contao/contao/blob/f3c7f25292fe3ccd1680c6c27b5b87cf1c3ea240/core-bundle/contao/templates/twig/component/_headline.html.twig#L22

Without {{ parent() }} this example would not work.

Copy link
Member

@netzarbeiter netzarbeiter left a comment

Choose a reason for hiding this comment

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

Thanky you, Fritz

@fritzmg fritzmg merged commit 1bfa137 into main Jun 1, 2025
@fritzmg fritzmg deleted the headline-template-faq branch June 1, 2025 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants