-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[TwigBundle] Enable #[AsTwigFilter]
, #[AsTwigFunction]
and #[AsTwigTest]
#20879
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
base: 7.3
Are you sure you want to change the base?
Conversation
I have no clue why the CI fails to build the docs, I can build it properly on my end 😞 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a few comments. I find it hard to juggle the old and new ways of doing things in the same doc without making it too complex to understand; but it looks fine to me the way it is.
Thanks for the comment GromNan, it's very appreciated especially since I'm still new to the doc repository. I'm slowly starting to get the hang of how to write it 🎉. I'll apply your suggestions tomorrow 😄 |
@@ -158,30 +158,23 @@ Twig Extension & Autoconfiguration | |||
|
|||
Thanks to Symfony's service handling, you can *extend* Symfony in many ways, like | |||
by creating an event subscriber or a security voter for complex authorization | |||
rules. Let's add a new filter to Twig called ``greet``. How? Create a class | |||
that extends ``AbstractExtension``:: | |||
rules. Let's add a new filter to Twig called ``greet``. How? Create a simple class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We avoid subjective words like "simple". "Plain" or nothing would be more adapted.
@@ -1608,6 +1600,16 @@ If you want to create a function instead of a filter, define the | |||
Along with custom filters and functions, you can also register | |||
`global variables`_. | |||
|
|||
.. versionadded:: 7.3 | |||
|
|||
Support for the ``#[AsTwigFilter]`` and ``#[AsTwigFunction]`` attributes was introduced in Symfony 7.3. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you can add the #[AsTwigTest]
to the list.
When using attributes to extend Twig, the services are initialized only when | ||
the functions or filters are used to render the template. But in case you use the | ||
classic approach by extending the ``AbstractExtension`` class, Twig initialize all extensions before | ||
rendering rendering any template, even if the template doesn't use an | ||
extension. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using attributes to extend Twig, the services are initialized only when | |
the functions or filters are used to render the template. But in case you use the | |
classic approach by extending the ``AbstractExtension`` class, Twig initialize all extensions before | |
rendering rendering any template, even if the template doesn't use an | |
extension. | |
When using attributes to extend Twig, the services are initialized only when | |
the functions or filters are used to render the template. But in case you use the | |
classic approach by extending the ``AbstractExtension`` class, Twig initializes all the extensions before | |
rendering any template, even if the extension is not used in the template. |
#[AsTwigTest]
#[AsTwigFilter]
, #[AsTwigFunction]
and #[AsTwigTest]
fix #20828
I did not listed the
AsTwigTest
attribute in the attributes list as no doc make mention of use case of this attribute. Do I had it anyway without any link to it (or a link to the twig documentation)?Also I hope my wording is correct, feel free to ask me any adjustment 😄
I followed the plan of @javiereguiluz