|
16 | 16 |
|
17 | 17 | .. note:: |
18 | 18 |
|
19 | | - How to render templates is covered in the :ref:`controller <controller-rendering-templates>` |
20 | | - page of the book. |
| 19 | + How to render templates is covered in the |
| 20 | + :ref:`controller <controller-rendering-templates>` page of the book. |
21 | 21 |
|
22 | 22 | .. index:: |
23 | 23 | single: Templating; What is a template? |
@@ -355,15 +355,15 @@ When working with template inheritance, here are some tips to keep in mind: |
355 | 355 | can use the ``{{ parent() }}`` function. This is useful if you want to add |
356 | 356 | to the contents of a parent block instead of completely overriding it: |
357 | 357 |
|
358 | | - .. code-block:: html+jinja |
| 358 | + .. code-block:: html+jinja |
359 | 359 |
|
360 | | - {% block sidebar %} |
361 | | - <h3>Table of Contents</h3> |
| 360 | + {% block sidebar %} |
| 361 | + <h3>Table of Contents</h3> |
362 | 362 |
|
363 | | - {# ... #} |
| 363 | + {# ... #} |
364 | 364 |
|
365 | | - {{ parent() }} |
366 | | - {% endblock %} |
| 365 | + {{ parent() }} |
| 366 | + {% endblock %} |
367 | 367 |
|
368 | 368 | .. index:: |
369 | 369 | single: Templating; Naming conventions |
@@ -444,9 +444,13 @@ Template Suffix |
444 | 444 | Every template name also has two extensions that specify the *format* and |
445 | 445 | *engine* for that template. |
446 | 446 |
|
447 | | -* **Blog/index.html.twig** - HTML format, Twig engine |
448 | | -* **Blog/index.html.php** - HTML format, PHP engine |
449 | | -* **Blog/index.css.twig** - CSS format, Twig engine |
| 447 | +======================== ====== ====== |
| 448 | +Filename Format Engine |
| 449 | +======================== ====== ====== |
| 450 | +``Blog/index.html.twig`` HTML Twig |
| 451 | +``Blog/index.html.php`` HTML PHP |
| 452 | +``Blog/index.css.twig`` CSS Twig |
| 453 | +======================== ====== ====== |
450 | 454 |
|
451 | 455 | By default, any Symfony template can be written in either Twig or PHP, and |
452 | 456 | the last part of the extension (e.g. ``.twig`` or ``.php``) specifies which |
@@ -556,7 +560,7 @@ Including this template from any other template is simple: |
556 | 560 | 'Article/articleDetails.html.php', |
557 | 561 | array('article' => $article) |
558 | 562 | ) ?> |
559 | | - <?php endforeach; ?> |
| 563 | + <?php endforeach ?> |
560 | 564 | <?php $view['slots']->stop() ?> |
561 | 565 |
|
562 | 566 | The template is included using the ``{{ include() }}`` function. Notice that the |
@@ -594,6 +598,10 @@ template. First, create a controller that renders a certain number of recent |
594 | 598 | articles:: |
595 | 599 |
|
596 | 600 | // src/AppBundle/Controller/ArticleController.php |
| 601 | + namespace AppBundle\Controller; |
| 602 | + |
| 603 | + // ... |
| 604 | + |
597 | 605 | class ArticleController extends Controller |
598 | 606 | { |
599 | 607 | public function recentArticlesAction($max = 3) |
@@ -1227,11 +1235,11 @@ bundles (see `KnpBundles.com`_) for a large number of different features. |
1227 | 1235 | Once you use a third-party bundle, you'll likely need to override and customize |
1228 | 1236 | one or more of its templates. |
1229 | 1237 |
|
1230 | | -Suppose you've included the imaginary open-source ``AcmeBlogBundle`` in your |
1231 | | -project (e.g. in the ``src/Acme/BlogBundle`` directory). And while you're |
1232 | | -really happy with everything, you want to override the blog "list" page to |
1233 | | -customize the markup specifically for your application. By digging into the |
1234 | | -``Blog`` controller of the ``AcmeBlogBundle``, you find the following:: |
| 1238 | +Suppose you've installed the imaginary open-source ``AcmeBlogBundle`` in your |
| 1239 | +project. And while you're really happy with everything, you want to override |
| 1240 | +the blog "list" page to customize the markup specifically for your application. |
| 1241 | +By digging into the ``Blog`` controller of the ``AcmeBlogBundle``, you find the |
| 1242 | +following:: |
1235 | 1243 |
|
1236 | 1244 | public function indexAction() |
1237 | 1245 | { |
|
0 commit comments