feat: add layouts.autoescape option#2388
Merged
Merged
Conversation
Introduce a new layouts.autoescape configuration to control Twig's autoescape behavior. The default config value is set in config/default.php, and the Twig renderer now reads this setting; if the value is null the renderer falls back to an extension-based strategy (js -> js, css -> css, html/empty -> html, others -> false). Documentation (English and French) updated with usage examples.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new layouts.autoescape configuration path for controlling Twig autoescaping, with renderer support and English/French documentation.
Changes:
- Reads
layouts.autoescapein the Twig renderer and uses an extension-based strategy when the value isnull. - Adds
layouts.autoescapeto the default configuration. - Documents the option and examples in English and French configuration docs.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Renderer/Twig.php |
Applies the configured Twig autoescape option and defines the null fallback strategy. |
config/default.php |
Adds the default layouts.autoescape config entry. |
docs/4-Configuration.md |
Documents the new option in English. |
docs/4-Configuration.fr.md |
Documents the new option in French. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds support for configuring the Twig
autoescapeoption for layouts, allowing users to set it explicitly or use an automatic strategy based on the template file extension. The documentation is updated in both English and French to explain the new configuration option and its behaviors.Configuration and rendering improvements:
layouts.autoescapeoption toconfig/default.php, allowing users to control Twig'sautoescapebehavior for templates. Setting it tonullenables an extension-based strategy.Twigrenderer insrc/Renderer/Twig.phpto use the newlayouts.autoescapeconfiguration. If set tonull, it determines the escaping strategy based on the template's extension (js,css,html, or none).Documentation updates:
layouts.autoescapeoption and its usage in the English configuration guide (docs/4-Configuration.md).docs/4-Configuration.fr.md).