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

[TwigBundle] Enable #[AsTwigFilter], #[AsTwigFunction] and `#[AsTwi… #20828

Open
fabpot opened this issue Mar 26, 2025 · 2 comments
Open

[TwigBundle] Enable #[AsTwigFilter], #[AsTwigFunction] and `#[AsTwi… #20828

fabpot opened this issue Mar 26, 2025 · 2 comments
Labels
good first issue Ideal for your first contribution! (some Symfony experience may be required) help wanted Issues and PRs which are looking for volunteers to complete them. Twig
Milestone

Comments

@fabpot
Copy link
Member

fabpot commented Mar 26, 2025

Q A
Feature PR symfony/symfony#52748
PR author(s) @GromNaN
Merged in 7.3

We created this issue to not forget to document this new feature. We would really appreciate if you can help us with this task. If you are not sure how to do it, please ask us and we will help you.

To fix this issue, please create a PR against the 7.3 branch in the symfony-docs repository.

Thank you! 😃

@fabpot fabpot added this to the 7.3 milestone Mar 26, 2025
@GromNaN
Copy link
Member

GromNaN commented Mar 26, 2025

Related Twig documentation: https://twig.symfony.com/doc/3.x/advanced.html#using-php-attributes-to-define-extensions

I propose to revise the Create the Extension Class chapter and use attributes instead of getFilters.
The next chapter on Creating Lazy-Loaded Twig Extensions is not really relevant since extension will be lazy-loaded by default using attributes. Is it necessary to keep this documentation part?

@javiereguiluz
Copy link
Member

Yes, I like this plan:

  • Update all Twig examples to use the new attributes
  • Add a versionadded directive (but only the first time) mentioning that the attributes were introduced in 7.3 and that in previous versions you had to use the getFilters() method, etc. Mentioning the old method names is important so folks used to the old methods can still find the page
  • I'd keep the section of lazy-loaded extensions (remove it in 8.x docs?) but I'd add a mention to the fact that when using attributes this is not needed anymore

Anybody willing to submit a Pull Request to fix this? Thanks!

@javiereguiluz javiereguiluz added good first issue Ideal for your first contribution! (some Symfony experience may be required) Twig help wanted Issues and PRs which are looking for volunteers to complete them. labels Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Ideal for your first contribution! (some Symfony experience may be required) help wanted Issues and PRs which are looking for volunteers to complete them. Twig
Projects
None yet
Development

No branches or pull requests

3 participants