From 10260209aee00bdf92b4727a726ff5da05fb2b29 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Tue, 28 Aug 2018 10:13:01 -0400 Subject: [PATCH] Documenting debug:twig command --- templating/debug.rst | 14 ++++++++++++++ templating/namespaced_paths.rst | 7 +++++++ templating/twig_extension.rst | 6 ++++++ 3 files changed, 27 insertions(+) diff --git a/templating/debug.rst b/templating/debug.rst index d270151fade..1491b385d79 100644 --- a/templating/debug.rst +++ b/templating/debug.rst @@ -67,3 +67,17 @@ By design, the ``dump()`` function is only available in the ``dev`` and ``test`` environments, to avoid leaking sensitive information in production. In fact, trying to use the ``dump()`` function in the ``prod`` environment will result in a PHP error. + +Execute this command to list all Twig functions, filters, globals, tests and +registered namespaces and their paths: + +.. code-block:: terminal + + # list general information + $ php bin/console debug:twig + + # filter output by any keyword + $ php bin/console debug:twig --filter=date + + # pass a template name to show the physical file which will be loaded + $ php bin/console debug:twig @Twig/Exception/error.html.twig diff --git a/templating/namespaced_paths.rst b/templating/namespaced_paths.rst index 59e76e7477f..2eda6764b99 100644 --- a/templating/namespaced_paths.rst +++ b/templating/namespaced_paths.rst @@ -71,6 +71,13 @@ in the ``vendor/acme/foo-bar/templates/`` directory, you can refer to it as: {{ include('@foo_bar/sidebar.twig') }} +Execute this command to verify if your template name is correct and know which +template file will be loaded: + +.. code-block:: terminal + + $ php bin/console debug:twig @foo_bar/sidebar.twig + Multiple Paths per Namespace ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/templating/twig_extension.rst b/templating/twig_extension.rst index cd30c6a3945..4d502abb70d 100644 --- a/templating/twig_extension.rst +++ b/templating/twig_extension.rst @@ -70,6 +70,12 @@ Next, register your class as a service and tag it with ``twig.extension``. If yo using the :ref:`default services.yaml configuration `, you're done! Symfony will automatically know about your new service and add the tag. +Execute this command to verify if your new filter was successfully registered: + +.. code-block:: terminal + + $ php bin/console debug:twig --filter=price + You can now start using your filter in any Twig template. Creating Lazy-Loaded Twig Extensions