Skip to content

Commit 754c7ce

Browse files
committed
minor #16676 [TwigBundle] Doc for config twig.file_name_pattern (GromNaN)
This PR was merged into the 6.1 branch. Discussion ---------- [TwigBundle] Doc for config `twig.file_name_pattern` Fix #16673 New feature of 6.1 Commits ------- 233f37a Doc for config twig.file_name_pattern
2 parents d340895 + 233f37a commit 754c7ce

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

reference/configuration/twig.rst

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,64 @@ The path to the directory where Symfony will look for the application Twig
166166
templates by default. If you store the templates in more than one directory, use
167167
the :ref:`paths <config-twig-paths>` option too.
168168

169+
.. _config-twig-file-name-pattern:
170+
171+
file_name_pattern
172+
~~~~~~~~~~~~~~~~~
173+
174+
**type**: ``string`` or ``array`` of ``string`` **default**: ``[]``
175+
176+
Name pattern of the Twig files in the template directories. The value can be a regexp,
177+
a glob, or a string. This is used by the commands ``lint:twig`` and ``cache:warmup``
178+
to find template files in all the configured paths.
179+
180+
.. configuration-block::
181+
182+
.. code-block:: yaml
183+
184+
# config/packages/twig.yaml
185+
twig:
186+
file_name_pattern: ['*.twig', 'specific_file.html']
187+
# ...
188+
189+
.. code-block:: xml
190+
191+
<!-- config/packages/twig.xml -->
192+
<?xml version="1.0" encoding="UTF-8" ?>
193+
<container xmlns="http://symfony.com/schema/dic/services"
194+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
195+
xmlns:twig="http://symfony.com/schema/dic/twig"
196+
xsi:schemaLocation="http://symfony.com/schema/dic/services
197+
https://symfony.com/schema/dic/services/services-1.0.xsd
198+
http://symfony.com/schema/dic/twig https://symfony.com/schema/dic/twig/twig-1.0.xsd">
199+
200+
<twig:config>
201+
<twig:file-name-pattern>*.twig</twig:file-name-pattern>
202+
<twig:file-name-pattern>specific_file.html</twig:file-name-pattern>
203+
<!-- ... -->
204+
</twig:config>
205+
</container>
206+
207+
.. code-block:: php
208+
209+
// config/packages/twig.php
210+
use Symfony\Config\TwigConfig;
211+
212+
return static function (TwigConfig $twig) {
213+
$twig->fileNamePattern([
214+
'*.twig',
215+
'specific_file.html',
216+
]);
217+
218+
// ...
219+
};
220+
221+
.. note::
222+
223+
By default, if the option is not set, the lint command filters on ``*.twig`` files.
224+
The cache warmer does not filter on file names and tries to compile all the
225+
files in the template directories; ignoring compilation errors.
226+
169227
.. _config-twig-form-themes:
170228

171229
form_themes

0 commit comments

Comments
 (0)