Skip to content

Commit 10e5d26

Browse files
committed
[book][page_creation] Fixing outdated base template name. Closes symfony#581
1 parent bce50c0 commit 10e5d26

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

book/page_creation.rst

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ controller, and ``index.html.twig`` the template:
314314
:linenos:
315315
316316
{# src/Acme/HelloBundle/Resources/views/Hello/index.html.twig #}
317-
{% extends '::layout.html.twig' %}
317+
{% extends '::base.html.twig' %}
318318
319319
{% block body %}
320320
Hello {{ name }}!
@@ -323,7 +323,7 @@ controller, and ``index.html.twig`` the template:
323323
.. code-block:: php
324324
325325
<!-- src/Acme/HelloBundle/Resources/views/Hello/index.html.php -->
326-
<?php $view->extend('::layout.html.php') ?>
326+
<?php $view->extend('::base.html.php') ?>
327327
328328
Hello <?php echo $view->escape($name) ?>!
329329
@@ -334,10 +334,10 @@ Let's step through the Twig template line-by-line:
334334

335335
* *line 4*: The ``block`` token says that everything inside should be placed
336336
inside a block called ``body``. As you'll see, it's the responsibility
337-
of the parent template (``layout.html.twig``) to ultimately render the
337+
of the parent template (``base.html.twig``) to ultimately render the
338338
block called ``body``.
339339

340-
The parent template, ``::layout.html.twig``, is missing both the **BundleName**
340+
The parent template, ``::base.html.twig``, is missing both the **BundleName**
341341
and **ControllerName** portions of its name (hence the double colon (``::``)
342342
at the beginning). This means that the template lives outside of the bundles
343343
and in the ``app`` directory:
@@ -346,29 +346,35 @@ and in the ``app`` directory:
346346

347347
.. code-block:: html+jinja
348348

349-
{# app/Resources/views/layout.html.twig #}
349+
{# app/Resources/views/base.html.twig #}
350350
<!DOCTYPE html>
351351
<html>
352352
<head>
353353
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
354-
<title>{% block title %}Hello Application{% endblock %}</title>
354+
<title>{% block title %}Welcome!{% endblock %}</title>
355+
{% block stylesheets %}{% endblock %}
356+
<link rel="shortcut icon" href="{{ asset('favicon.ico') }}" />
355357
</head>
356358
<body>
357359
{% block body %}{% endblock %}
360+
{% block javascripts %}{% endblock %}
358361
</body>
359362
</html>
360363

361364
.. code-block:: php
362365
363-
<!-- app/Resources/views/layout.html.php -->
366+
<!-- app/Resources/views/base.html.php -->
364367
<!DOCTYPE html>
365368
<html>
366369
<head>
367370
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
368-
<title><?php $view['slots']->output('title', 'Hello Application') ?></title>
371+
<title><?php $view['slots']->output('title', 'Welcome!') ?></title>
372+
<?php $view['slots']->output('stylesheets') ?>
373+
<link rel="shortcut icon" href="<?php echo $view['assets']->getUrl('favicon.ico') ?>" />
369374
</head>
370375
<body>
371376
<?php $view['slots']->output('_content') ?>
377+
<?php $view['slots']->output('stylesheets') ?>
372378
</body>
373379
</html>
374380

0 commit comments

Comments
 (0)