Skip to content

Document the escape Twig filter #1571

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Document the escape Twig filter #1571

wants to merge 2 commits into from

Conversation

fritzmg
Copy link
Contributor

@fritzmg fritzmg commented Apr 19, 2025

@ausi @m-vo I would need some help here. I want to document the exact differences of the escape strategy that Contao introduces - and also document examples regarding ChunkedText from insert tags.

@ausi
Copy link
Member

ausi commented Apr 20, 2025

The escape differences are described here: https://docs.contao.org/dev/framework/templates/architecture/#double-encoding-prevention

A ChunkedText object contains strings that need to be escaped and other strings that are kept raw. So {{ text|insert_tag_raw|escape('html') }} only escapes the parts that do not come from the replaced insert tags. However this is not directly related to the Contao escaper, this should work in all Twig templates (not only @Contao and @Contao_*). See https://github.com/contao/contao/blob/4f485fe5410d7ec1e7c9efc9ee5972844d094aec/core-bundle/src/Twig/Extension/ContaoExtension.php#L282-L292

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.

2 participants