8000 Update most important book articles to follow the best practices by wouterj · Pull Request #4427 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Update most important book articles to follow the best practices #4427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Nov 7, 2014
Merged
Prev Previous commit
Next Next commit
Other random fixes
  • Loading branch information
wouterj committed Nov 6, 2014
commit 10b3c7c8d6b3da1e97ddee060bc9b5f346456d9e
42 changes: 25 additions & 17 deletions book/templating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ code.

.. note::

How to render templates is covered in the :ref:`controller <controller-rendering-templates>`
page of the book.
How to render templates is covered in the
:ref:`controller <controller-rendering-templates>` page of the book.

.. index::
single: Templating; What is a template?
Expand Down Expand Up @@ -355,15 +355,15 @@ When working with template inheritance, here are some tips to keep in mind:
can use the ``{{ parent() }}`` function. This is useful if you want to add
to the contents of a parent block instead of completely overriding it:

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

{% block sidebar %}
<h3>Table of Contents</h3>
{% block sidebar %}
<h3>Table of Contents</h3>

{# ... #}
{# ... #}

{{ parent() }}
{% endblock %}
{{ parent() }}
{% endblock %}

.. index::
single: Templating; Naming conventions
Expand Down Expand Up @@ -444,9 +444,13 @@ Template Suffix
Every template name also has two extensions that specify the *format* and
*engine* for that template.

* **Blog/index.html.twig** - HTML format, Twig engine
* **Blog/index.html.php** - HTML format, PHP engine
* **Blog/index.css.twig** - CSS format, Twig engine
======================== ====== ======
Filename Format Engine
======================== ====== ======
``Blog/index.html.twig`` HTML Twig
``Blog/index.html.php`` HTML PHP
``Blog/index.css.twig`` CSS Twig
======================== ====== ======

By default, any Symfony template can be written in either Twig or PHP, and
the last part of the extension (e.g. ``.twig`` or ``.php``) specifies which
Expand Down Expand Up @@ -556,7 +560,7 @@ Including this template from any other template is simple:
'Article/articleDetails.html.php',
array('article' => $article)
) ?>
<?php endforeach; ?>
<?php endforeach ?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In most of the PHP template examples, we use the semicolon after endif, endforeach and so on. I'm not sure if we better avoid it in general or keep it at all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've always trimmed the last semi-colon in PHP templates. Again, let's tackle this in another ticket

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the records, this was done in #4436.

<?php $view['slots']->stop() ?>

The template is included using the ``{{ include() }}`` function. Notice that the
Expand Down Expand Up @@ -594,6 +598,10 @@ template. First, create a controller that renders a certain number of recent
articles::

// src/AppBundle/Controller/ArticleController.php
namespace AppBundle\Controller;

// ...

class ArticleController extends Controller
{
public function recentArticlesAction($max = 3)
Expand Down Expand Up @@ -1227,11 +1235,11 @@ bundles (see `KnpBundles.com`_) for a large number of different features.
Once you use a third-party bundle, you'll likely need to override and customize
one or more of its templates.

Suppose you've included the imaginary open-source ``AcmeBlogBundle`` in your
project (e.g. in the ``src/Acme/BlogBundle`` directory). And while you're
really happy with everything, you want to override the blog "list" page to
customize the markup specifically for your application. By digging into the
``Blog`` controller of the ``AcmeBlogBundle``, you find the following::
Suppose you've installed the imaginary open-source ``AcmeBlogBundle`` in your
project. And while you're really happy with everything, you want to override
the blog "list" page to customize the markup specifically for your application.
By digging into the ``Blog`` controller of the ``AcmeBlogBundle``, you find the
following::

public function indexAction()
{
Expand Down
0