From af245fcbf3e0bff3c62ef03fe2bfedc88c0d8ec7 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Tue, 24 Oct 2017 13:54:40 -0400 Subject: [PATCH 1/2] Add default_path option reference --- reference/configuration/twig.rst | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/reference/configuration/twig.rst b/reference/configuration/twig.rst index 526362f635c..3d1522dc27b 100644 --- a/reference/configuration/twig.rst +++ b/reference/configuration/twig.rst @@ -54,6 +54,7 @@ TwigBundle Configuration ("twig") strict_variables: ~ auto_reload: ~ optimizations: ~ + default_path: '%kernel.project_dir%/templates' paths: '%kernel.project_dir%/vendor/acme/foo-bar/templates': foo_bar @@ -87,6 +88,7 @@ TwigBundle Configuration ("twig") debug="%kernel.debug%" strict-variables="false" optimizations="true" + default-path="%kernel.project_dir%/templates" > form_div_layout.html.twig form.html.twig @@ -136,6 +138,7 @@ TwigBundle Configuration ("twig") 'decimal_point' => ',', 'thousands_separator' => '.', ), + 'default_path' => '%kernel.project_dir%/templates', )); .. caution:: @@ -338,6 +341,17 @@ on. Set it to ``0`` to disable all the optimizations. You can even enable or disable these optimizations selectively, as explained in the Twig documentation about `the optimizer extension`_. +default_path +~~~~~~~~~~~~ + +**type**: ``string`` **default**: ``'%kernel.project_dir%/templates'`` + +.. versionadded:: 3.4 + + The ``default_path`` option was introduced in Symfony 3.4. + +The default directory where Symfony will look for Twig templates. + .. _config-twig-paths: paths @@ -346,9 +360,13 @@ paths **type**: ``array`` **default**: ``null`` This option defines the directories where Symfony will look for Twig templates -in addition to the default locations (``app/Resources/views/`` and the bundles' -``Resources/views/`` directories). This is useful to integrate the templates -included in some library or package used by your application. +in addition to the default locations. Symfony looks for the templates in the +following order: + +1. The directories defined in this option; +2. The ``Resources/views/`` directories of the bundles used in the application. +3. The ``src/Resources/views/`` directory of the application; +4. The directory defined in the ``default_path`` option; The values of the ``paths`` option are defined as ``key: value`` pairs where the ``value`` part can be ``null``. For example: From 66fd357c25f05760a509359cf02386de3287324f Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 26 Oct 2017 10:34:58 +0200 Subject: [PATCH 2/2] Minor tweaks --- reference/configuration/twig.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/reference/configuration/twig.rst b/reference/configuration/twig.rst index 3d1522dc27b..344842212a2 100644 --- a/reference/configuration/twig.rst +++ b/reference/configuration/twig.rst @@ -347,7 +347,6 @@ default_path **type**: ``string`` **default**: ``'%kernel.project_dir%/templates'`` .. versionadded:: 3.4 - The ``default_path`` option was introduced in Symfony 3.4. The default directory where Symfony will look for Twig templates. @@ -364,9 +363,9 @@ in addition to the default locations. Symfony looks for the templates in the following order: 1. The directories defined in this option; -2. The ``Resources/views/`` directories of the bundles used in the application. +2. The ``Resources/views/`` directories of the bundles used in the application; 3. The ``src/Resources/views/`` directory of the application; -4. The directory defined in the ``default_path`` option; +4. The directory defined in the ``default_path`` option. The values of the ``paths`` option are defined as ``key: value`` pairs where the ``value`` part can be ``null``. For example: