mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-21 15:48:42 +00:00
tweaked docs
This commit is contained in:
@@ -1628,6 +1628,9 @@ is ignored. To avoid name conflicts, you can rename imported blocks:
|
|||||||
{% block title %}{% endblock %}
|
{% block title %}{% endblock %}
|
||||||
{% block content %}{% endblock %}
|
{% block content %}{% endblock %}
|
||||||
|
|
||||||
|
.. versionadded:: 1.3
|
||||||
|
The ``parent()`` support was added in Twig 1.3.
|
||||||
|
|
||||||
The ``parent()`` function automatically determines the correct inheritance
|
The ``parent()`` function automatically determines the correct inheritance
|
||||||
tree, so it can be used when overriding a block defined in an imported
|
tree, so it can be used when overriding a block defined in an imported
|
||||||
template:
|
template:
|
||||||
@@ -1648,6 +1651,21 @@ template:
|
|||||||
In this example, ``parent()`` will correctly call the ``sidebar`` block from
|
In this example, ``parent()`` will correctly call the ``sidebar`` block from
|
||||||
the ``blocks.html`` template.
|
the ``blocks.html`` template.
|
||||||
|
|
||||||
|
.. tip::
|
||||||
|
|
||||||
|
In Twig 1.2, renaming allows you to simulate inheritance by calling the
|
||||||
|
"parent" block:
|
||||||
|
|
||||||
|
.. code-block:: jinja
|
||||||
|
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% use "blocks.html" with sidebar as parent_sidebar %}
|
||||||
|
|
||||||
|
{% block sidebar %}
|
||||||
|
{{ block('parent_sidebar') }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
You can use as many ``use`` statements as you want in any given template.
|
You can use as many ``use`` statements as you want in any given template.
|
||||||
|
|||||||
Reference in New Issue
Block a user