Skip to content

Commit 52e21f3

Browse files
committed
Merge branch '2.3' into 2.5
* 2.3: [#4928] Backporting change after merging into 2.5 (since 2.3 is a little different) Fixed a minor RST syntax issue Added a reference about including JS and CSS files in PHP templates Removed the Stable API chapter from the Symfony book Conflicts: book/stable_api.rst components/debug/introduction.rst
2 parents 008c4de + 0afc689 commit 52e21f3

File tree

5 files changed

+58
-82
lines changed

5 files changed

+58
-82
lines changed

Diff for: book/index.rst

-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,5 @@ The Book
2222
service_container
2323
performance
2424
internals
25-
stable_api
2625

2726
.. include:: /book/map.rst.inc

Diff for: book/map.rst.inc

-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@
1616
* :doc:`/book/service_container`
1717
* :doc:`/book/performance`
1818
* :doc:`/book/internals`
19-
* :doc:`/book/stable_api`

Diff for: book/stable_api.rst

-56
This file was deleted.

Diff for: book/templating.rst

+57-24
Original file line numberDiff line numberDiff line change
@@ -1091,43 +1091,76 @@ one called ``stylesheets`` inside the ``head`` tag and another called ``javascri
10911091
just above the closing ``body`` tag. These blocks will contain all of the
10921092
stylesheets and JavaScripts that you'll need throughout your site:
10931093

1094-
.. code-block:: html+jinja
1094+
.. configuration-block::
10951095

1096-
{# app/Resources/views/base.html.twig #}
1097-
<html>
1098-
<head>
1099-
{# ... #}
1096+
.. code-block:: html+jinja
11001097

1101-
{% block stylesheets %}
1102-
<link href="{{ asset('css/main.css') }}" rel="stylesheet" />
1103-
{% endblock %}
1104-
</head>
1105-
<body>
1106-
{# ... #}
1098+
{# app/Resources/views/base.html.twig #}
1099+
<html>
1100+
<head>
1101+
{# ... #}
11071102

1108-
{% block javascripts %}
1109-
<script src="{{ asset('js/main.js') }}"></script>
1110-
{% endblock %}
1111-
</body>
1112-
</html>
1103+
{% block stylesheets %}
1104+
<link href="{{ asset('css/main.css') }}" rel="stylesheet" />
1105+
{% endblock %}
1106+
</head>
1107+
<body>
1108+
{# ... #}
1109+
1110+
{% block javascripts %}
1111+
<script src="{{ asset('js/main.js') }}"></script>
1112+
{% endblock %}
1113+
</body>
1114+
</html>
1115+
1116+
.. code-block:: php
1117+
1118+
// app/Resources/views/base.html.php
1119+
<html>
1120+
<head>
1121+
<?php ... ?>
1122+
1123+
<?php $view['slots']->start('stylesheets') ?>
1124+
<link href="<?php echo $view['assets']->getUrl('css/main.css') ?>" rel="stylesheet" />
1125+
<?php $view['slots']->stop() ?>
1126+
</head>
1127+
<body>
1128+
<?php ... ?>
1129+
1130+
<?php $view['slots']->start('javascripts') ?>
1131+
<script src="<?php echo $view['assets']->getUrl('js/main.js') ?>"></script>
1132+
<?php $view['slots']->stop() ?>
1133+
</body>
1134+
</html>
11131135
11141136
That's easy enough! But what if you need to include an extra stylesheet or
11151137
JavaScript from a child template? For example, suppose you have a contact
11161138
page and you need to include a ``contact.css`` stylesheet *just* on that
11171139
page. From inside that contact page's template, do the following:
11181140

1119-
.. code-block:: html+jinja
1141+
.. configuration-block::
1142+
1143+
.. code-block:: html+jinja
1144+
1145+
{# app/Resources/views/Contact/contact.html.twig #}
1146+
{% extends 'base.html.twig' %}
1147+
1148+
{% block stylesheets %}
1149+
{{ parent() }}
1150+
1151+
<link href="{{ asset('css/contact.css') }}" rel="stylesheet" />
1152+
{% endblock %}
11201153

1121-
{# app/Resources/views/Contact/contact.html.twig #}
1122-
{% extends 'base.html.twig' %}
1154+
{# ... #}
11231155

1124-
{% block stylesheets %}
1125-
{{ parent() }}
1156+
.. code-block:: php
11261157
1127-
<link href="{{ asset('css/contact.css') }}" rel="stylesheet" />
1128-
{% endblock %}
1158+
// app/Resources/views/Contact/contact.html.twig
1159+
<?php $view->extend('base.html.php') ?>
11291160
1130-
{# ... #}
1161+
<?php $view['slots']->start('stylesheets') ?>
1162+
<link href="<?php echo $view['assets']->getUrl('css/contact.css') ?>" rel="stylesheet" />
1163+
<?php $view['slots']->stop() ?>
11311164
11321165
In the child template, you simply override the ``stylesheets`` block and
11331166
put your new stylesheet tag inside of that block. Of course, since you want

Diff for: redirection_map

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/book/stable_api /contributing/code/bc
12
/cookbook/deployment-tools /cookbook/deployment/tools
23
/cookbook/doctrine/migrations /bundles/DoctrineFixturesBundle/index
34
/cookbook/doctrine/doctrine_fixtures /bundles/DoctrineFixturesBundle/index

0 commit comments

Comments
 (0)