Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
javiereguiluz merged 1 commit intosymfony:4.4fromCJDennis:patch-1
May 3, 2022
Merged
Changes fromall 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 deletionstemplating/twig_extension.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,8 +4,8 @@
How to Write a custom Twig Extension
====================================

`Twig Extensions`_ allowto createcustom functions, filters and more to use
themin your Twig templates. Before writing your own Twig extension, check if
`Twig Extensions`_ allowthe creation ofcustom 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 DownExpand 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 allowsto decouple the extension definition from its
That's why Twig allowsdecoupling 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

[8]ページ先頭

©2009-2025 Movatter.jp