Skip to content

Commit 413e1a4

Browse files
committed
Add default_path option reference
1 parent f8ddf1f commit 413e1a4

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

reference/configuration/twig.rst

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ TwigBundle Configuration ("twig")
6767
decimal_point: ','
6868
thousands_separator: '.'
6969
70+
# The following was added in Symfony 3.4.
71+
default_path: '%kernel.project_dir%/templates'
72+
7073
.. code-block:: xml
7174
7275
<!-- app/config/config.xml -->
@@ -87,6 +90,7 @@ TwigBundle Configuration ("twig")
8790
debug="%kernel.debug%"
8891
strict-variables="false"
8992
optimizations="true"
93+
default-path="%kernel.project_dir%/templates"
9094
>
9195
<twig:form-theme>form_div_layout.html.twig</twig:form-theme> <!-- Default -->
9296
<twig:form-theme>form.html.twig</twig:form-theme>
@@ -136,6 +140,7 @@ TwigBundle Configuration ("twig")
136140
'decimal_point' => ',',
137141
'thousands_separator' => '.',
138142
),
143+
'default_path' => '%kernel.project_dir%/templates',
139144
));
140145
141146
.. caution::
@@ -338,6 +343,13 @@ on. Set it to ``0`` to disable all the optimizations. You can even enable or
338343
disable these optimizations selectively, as explained in the Twig documentation
339344
about `the optimizer extension`_.
340345

346+
default_path
347+
~~~~~~~~~~~~
348+
349+
**type**: ``string`` **default**: ``'%kernel.project_dir%/templates'``
350+
351+
The default directory where Symfony will look for Twig templates.
352+
341353
.. _config-twig-paths:
342354

343355
paths
@@ -346,9 +358,13 @@ paths
346358
**type**: ``array`` **default**: ``null``
347359

348360
This option defines the directories where Symfony will look for Twig templates
349-
in addition to the default locations (``app/Resources/views/`` and the bundles'
350-
``Resources/views/`` directories). This is useful to integrate the templates
351-
included in some library or package used by your application.
361+
in addition to the default locations. Symfony looks for the templates in the
362+
following order:
363+
364+
1. The directories defined in this option;
365+
2. The ``src/Resources/views/`` directory of the application;
366+
3. The directory defined in the ``default_path`` option;
367+
4. The ``Resources/views/`` directories of the bundles used in the application.
352368

353369
The values of the ``paths`` option are defined as ``key: value`` pairs where the
354370
``value`` part can be ``null``. For example:

0 commit comments

Comments
 (0)