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

Extract the escaping logic to a runtime #4055

Merged
merged 5 commits into from
May 1, 2024
Merged

Conversation

fabpot
Copy link
Contributor

@fabpot fabpot commented Apr 28, 2024

No description provided.

@fabpot fabpot force-pushed the escaper-runtime branch 7 times, most recently from b03c16f to 60c1417 Compare April 28, 2024 19:25
@fabpot fabpot force-pushed the escaper-runtime branch 2 times, most recently from aa30dca to 3e742f9 Compare April 29, 2024 06:10
@smnandre
Copy link
Contributor

 If you were using the ``twig_escape_filter()`` function is your code, use
 ``$env->getRuntime(EscaperRuntime::class)->escape()`` instead.

For once, i'd suggest to add some "magic" because the DX seem a bit odd (to me)..

Could we expose directly something like ?

$env->getEscaper()

With maybe a dedicated interface ?

@fabpot
Copy link
Contributor Author

fabpot commented Apr 30, 2024

 If you were using the ``twig_escape_filter()`` function is your code, use
 ``$env->getRuntime(EscaperRuntime::class)->escape()`` instead.

For once, i'd suggest to add some "magic" because the DX seem a bit odd (to me)..

Could we expose directly something like ?

$env->getEscaper()

With maybe a dedicated interface ?

I don't think we need a "nicer" DX as using this directly should be the exception, not the rule.

doc/deprecated.rst Outdated Show resolved Hide resolved
@fabpot fabpot merged commit c2c2058 into twigphp:3.x May 1, 2024
72 of 76 checks passed
@fabpot fabpot deleted the escaper-runtime branch May 1, 2024 07:14
* @param string $strategy The strategy name that should be used as a strategy in the escape call
* @param callable $callable A valid PHP callable
* @param string $strategy The strategy name that should be used as a strategy in the escape call
* @param callable(Environment, string) $callable A valid PHP callable
Copy link
Member

Choose a reason for hiding this comment

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

The callable also receives the charset as a third argument.

src/Extension/EscaperExtension.php Show resolved Hide resolved
src/NodeVisitor/EscaperNodeVisitor.php Show resolved Hide resolved
derrabus added a commit to symfony/symfony that referenced this pull request May 2, 2024
This PR was merged into the 5.4 branch.

Discussion
----------

[WebProfilerBundle] fix compatibility with Twig 3.10

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Issues        |
| License       | MIT

see twigphp/Twig#4055

Commits
-------

a4190b5 fix compatibility with Twig 3.10
kbond added a commit to symfony/ux that referenced this pull request May 8, 2024
This PR was merged into the 2.x branch.

Discussion
----------

[Stimulus] Use Twig >3.9 'EscaperRuntime'

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| Issues        | Fix #...
| License       | MIT

Resolves CI deprecations (for > Twig 3.9)

Twig introduction of EscaperRuntime here: twigphp/Twig#4055

Commits
-------

1fe2ae3 [Stimulus] Use Twig >3.9 'EscaperRuntime'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants