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

fix spaceless deprecation #399

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

Conversation

garak
Copy link
Collaborator

@garak garak commented Sep 7, 2024

Fix #395

@garak garak requested review from stof and alexpozzi September 7, 2024 14:03
.github/workflows/build.yaml Outdated Show resolved Hide resolved
.github/workflows/build.yaml Outdated Show resolved Hide resolved
@@ -36,6 +36,7 @@ public function getFilters(): array
{
return [
new TwigFilter('knp_menu_as_string', [$this, 'pathAsString']),
new TwigFilter('knp_menu_spaceless', [$this, 'spaceless'], ['is_safe' => ['html']]),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we rather deprecate our compressed_root block instead of providing our own spaceless filter suffering from the same shortcomings than the Twig one that has been deprecated because of them ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My initial idea was just about making out tests not failing about the twig deprecation, but I didn't manage to get it (using the environment variable SYMFONY_DEPRECATIONS_HELPER didn't work).
If we deprecated our internal block, we'll end up with the same problem (tests failing because of the deprecation)

Copy link
Contributor

Choose a reason for hiding this comment

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

There's certainly room to take advantage of newer Symfony technologies in this package, although even moreso in the bundle. Like replacing the macros with Twig Components or even some twig helper functions/filters .

@tacman
Copy link
Contributor

tacman commented Feb 6, 2025

Any chance this can be merged and a new release can be published? Twig 4 will be out soon, better to get ahead of this. Every one of my sites uses this wonderful library, so I see this message all the time.

 c:c --env=prod

 // Clearing the cache for the prod environment with debug false                                                        

[2025-02-06T15:19:57.084445+00:00] deprecation.INFO: User Deprecated: Since twig/twig 3.12: Twig Filter "spaceless" is deprecated in /home/tac/g/sites/member-directory/vendor/knplabs/knp-menu/src/Knp/Menu/Resources/views/knp_menu.html.twig at line 12. {"exception":"[object] (ErrorException(code: 0): User Deprecated: Since twig/twig 3.12: Twig Filter \"spaceless\" is deprecated in /home/tac/g/sites/member-directory/vendor/knplabs/knp-menu/src/Knp/Menu/Resources/views/knp_menu.html.twig at line 12. at /home/tac/g/sites/member-directory/vendor/twig/twig/src/DeprecatedCallableInfo.php:65)"} []
                                                                                                                        
 [OK] Cache for the "prod" environment (debug=false) was successfully cleared.                                          

@garak
Copy link
Collaborator Author

garak commented Feb 7, 2025

I rebased this PR and updated it, now the CI passes without deprecations.

The question raised by @stof is still open, though. This update would formally allow the library to be used with Twig 4, but the possible problem with the spaceless filter is not solved.

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.

Twig spaceless deprecation
3 participants