1``block``
2=========
3
4When a template uses inheritance and if you want to print a block multiple
5times, use the ``block`` function:
6
7.. code-block:: html+twig
8
9    <title>{% block title %}{% endblock %}</title>
10
11    <h1>{{ block('title') }}</h1>
12
13    {% block body %}{% endblock %}
14
15The ``block`` function can also be used to display one block from another
16template:
17
18.. code-block:: twig
19
20    {{ block("title", "common_blocks.twig") }}
21
22Use the ``defined`` test to check if a block exists in the context of the
23current template:
24
25.. code-block:: twig
26
27    {% if block("footer") is defined %}
28        ...
29    {% endif %}
30
31    {% if block("footer", "common_blocks.twig") is defined %}
32        ...
33    {% endif %}
34
35.. seealso::
36
37    :doc:`extends<../tags/extends>`, :doc:`parent<../functions/parent>`
38