Skip to content

Add default_path option reference #8549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions reference/configuration/twig.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -87,6 +88,7 @@ TwigBundle Configuration ("twig")
debug="%kernel.debug%"
strict-variables="false"
optimizations="true"
default-path="%kernel.project_dir%/templates"
>
<twig:form-theme>form_div_layout.html.twig</twig:form-theme> <!-- Default -->
<twig:form-theme>form.html.twig</twig:form-theme>
Expand Down Expand Up @@ -136,6 +138,7 @@ TwigBundle Configuration ("twig")
'decimal_point' => ',',
'thousands_separator' => '.',
),
'default_path' => '%kernel.project_dir%/templates',
));

.. caution::
Expand Down Expand Up @@ -338,6 +341,16 @@ 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
Expand All @@ -346,9 +359,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:
Expand Down