Skip to content

Commit af245fc

Browse files
committed
Add default_path option reference
1 parent f8ddf1f commit af245fc

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

reference/configuration/twig.rst

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ TwigBundle Configuration ("twig")
5454
strict_variables: ~
5555
auto_reload: ~
5656
optimizations: ~
57+
default_path: '%kernel.project_dir%/templates'
5758
paths:
5859
'%kernel.project_dir%/vendor/acme/foo-bar/templates': foo_bar
5960
@@ -87,6 +88,7 @@ TwigBundle Configuration ("twig")
8788
debug="%kernel.debug%"
8889
strict-variables="false"
8990
optimizations="true"
91+
default-path="%kernel.project_dir%/templates"
9092
>
9193
<twig:form-theme>form_div_layout.html.twig</twig:form-theme> <!-- Default -->
9294
<twig:form-theme>form.html.twig</twig:form-theme>
@@ -136,6 +138,7 @@ TwigBundle Configuration ("twig")
136138
'decimal_point' => ',',
137139
'thousands_separator' => '.',
138140
),
141+
'default_path' => '%kernel.project_dir%/templates',
139142
));
140143
141144
.. caution::
@@ -338,6 +341,17 @@ on. Set it to ``0`` to disable all the optimizations. You can even enable or
338341
disable these optimizations selectively, as explained in the Twig documentation
339342
about `the optimizer extension`_.
340343

344+
default_path
345+
~~~~~~~~~~~~
346+
347+
**type**: ``string`` **default**: ``'%kernel.project_dir%/templates'``
348+
349+
.. versionadded:: 3.4
350+
351+
The ``default_path`` option was introduced in Symfony 3.4.
352+
353+
The default directory where Symfony will look for Twig templates.
354+
341355
.. _config-twig-paths:
342356

343357
paths
@@ -346,9 +360,13 @@ paths
346360
**type**: ``array`` **default**: ``null``
347361

348362
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.
363+
in addition to the default locations. Symfony looks for the templates in the
364+
following order:
365+
366+
1. The directories defined in this option;
367+
2. The ``Resources/views/`` directories of the bundles used in the application.
368+
3. The ``src/Resources/views/`` directory of the application;
369+
4. The directory defined in the ``default_path`` option;
352370

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

0 commit comments

Comments
 (0)