Skip to content

[Twig] Update twig_extension.rst #16769

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

Merged
merged 1 commit into from
May 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions templating/twig_extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
How to Write a custom Twig Extension
====================================

`Twig Extensions`_ allow to create custom functions, filters and more to use
them in your Twig templates. Before writing your own Twig extension, check if
`Twig Extensions`_ allow the creation of custom functions, filters, and more to use
in your Twig templates. Before writing your own Twig extension, check if
the filter/function that you need is already implemented in:

* The `default Twig filters and functions`_;
Expand All @@ -16,7 +16,7 @@ Create the Extension Class
--------------------------

Suppose you want to create a new filter called ``price`` that formats a number
into money:
as currency:

.. code-block:: twig

Expand Down Expand Up @@ -117,7 +117,7 @@ them) performance is not affected. However, if extensions define lots of complex
dependencies (e.g. those making database connections), the performance loss can
be significant.

That's why Twig allows to decouple the extension definition from its
That's why Twig allows decoupling the extension definition from its
implementation. Following the same example as before, the first change would be
to remove the ``formatPrice()`` method from the extension and update the PHP
callable defined in ``getFilters()``::
Expand Down