From 0084f140d5ad04c2dd42b97119b33725cd2ea291 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 11 Jan 2018 16:46:45 +0100 Subject: [PATCH] Mention the official Twig extensions --- templating/twig_extension.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/templating/twig_extension.rst b/templating/twig_extension.rst index 014c2e0d1e9..386fe1816f5 100644 --- a/templating/twig_extension.rst +++ b/templating/twig_extension.rst @@ -8,6 +8,17 @@ If you need to create custom Twig functions, filters, tests or more, you'll need to create a Twig extension. You can read more about `Twig Extensions`_ in the Twig documentation. +.. tip:: + + Before writing your own Twig extension, check if the filter/function that + you need is already implemented in the :doc:`Symfony Twig extensions `. + Check also the `official Twig extensions`_, which can be installed in your + application as follows: + + .. code-block:: terminal + + $ composer require twig/extensions + Create the Extension Class -------------------------- @@ -62,6 +73,7 @@ you're done! Symfony will automatically know about your new service and add the You can now start using your filter in any Twig template. +.. _`official Twig extensions`: https://github.com/twigphp/Twig-extensions .. _`Twig extensions documentation`: http://twig.sensiolabs.org/doc/advanced.html#creating-an-extension .. _`global variables`: http://twig.sensiolabs.org/doc/advanced.html#id1 .. _`functions`: http://twig.sensiolabs.org/doc/advanced.html#id2