@@ -388,12 +388,21 @@ By default, templates can live in two different locations:
388
388
389
389
* ``path/to/bundle/Resources/views/ ``: Each third party bundle houses its
390
390
templates in its ``Resources/views `` directory (and subdirectories). When you
391
- plan to share your bundle, you should put the templates in the shared bundle
392
- instead of the ``app/Resources/views `` directory.
391
+ plan to share your bundle, you should put the templates in the bundle instead
392
+ of the ``app/ `` directory.
393
+
394
+ Most of the templates you'll use live in the ``app/Resources/views/ ``
395
+ directory. The path you'll use will be relative to this directory. For example,
396
+ to render/extend ``app/Resources/views/base.html.twig ``, you'll use the
397
+ ``base.html.twig `` path and to render/extend
398
+ ``app/Resources/views/Blog/index.html.twig ``, you'll use the
399
+ ``Blog/index.html.twig `` path.
400
+
401
+ Referencing Templates in a Bundle
402
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
393
403
394
404
Symfony uses a **bundle **:**directory **:**filename ** string syntax for
395
- templates. You can also give paths, which are relative to the
396
- ``app/Resources/views `` directory. This allows for several different types of
405
+ templates that live inside a bundle. This allows for several different types of
397
406
templates, each which lives in a specific location:
398
407
399
408
* ``AcmeBlogBundle:Blog:index.html.twig ``: This syntax is used to specify a
@@ -419,24 +428,15 @@ templates, each which lives in a specific location:
419
428
Yes, there are 2 colons in the middle of the string when the "controller"
420
429
subdirectory part is missing.
421
430
422
- * ``::base.html.twig ``: This syntax refers to views in ``app/Resources/views ``.
423
- Notice that the string begins with two colons (``:: ``), meaning that both the
424
- *bundle * and *directory * portions are missing. This means that the template
425
- is not located in any bundle, but instead in the root
426
- ``app/Resources/views/ `` directory.
427
-
428
- * ``base.html.twig ``: Equivalent to ``::base.html.twig `` and **recommended **
429
- for application-wide templates.
430
-
431
431
In the :ref: `overriding-bundle-templates ` section, you'll find out how each
432
432
template living inside the ``AcmeBlogBundle ``, for example, can be overridden
433
433
by placing a template of the same name in the ``app/Resources/AcmeBlogBundle/views/ ``
434
434
directory. This gives the power to override templates from any vendor bundle.
435
435
436
436
.. tip ::
437
437
438
- Hopefully the template naming syntax looks familiar - it's the same naming
439
- convention used to refer to :ref: `controller-string-syntax `.
438
+ Hopefully the template naming syntax looks familiar - it's similair to the
439
+ naming convention used to refer to :ref: `controller-string-syntax `.
440
440
441
441
Template Suffix
442
442
~~~~~~~~~~~~~~~
@@ -1322,7 +1322,7 @@ covered:
1322
1322
template is called ``base.html.twig ``;
1323
1323
1324
1324
* Create a template for each "section" of your site. For example, the blog
1325
- functionality would have a template called ``/ Blog/layout.html.twig `` that
1325
+ functionality would have a template called ``Blog/layout.html.twig `` that
1326
1326
contains only blog section-specific elements;
1327
1327
1328
1328
.. code-block :: html+jinja
0 commit comments