Lines Matching refs:block

15 .. code-block:: html+jinja
20 {% block head %}
22 <title>{% block title %}{% endblock %} - My Webpage</title>
26 <div id="content">{% block content %}{% endblock %}</div>
28 {% block footer %}
35 In this example, the :doc:`block<block>` tags define four blocks that child
38 All the ``block`` tag does is to tell the template engine that a child
46 .. code-block:: jinja
50 {% block title %}Index{% endblock %}
51 {% block head %}
57 {% block content %}
69 Note that since the child template doesn't define the ``footer`` block, the
72 You can't define multiple ``block`` tags with the same name in the same
73 template. This limitation exists because a block tag works in "both"
74 directions. That is, a block tag doesn't just provide a hole to fill - it also
76 similarly-named ``block`` tags in a template, that template's parent wouldn't
79 If you want to print a block multiple times you can however use the
80 ``block`` function:
82 .. code-block:: jinja
84 <title>{% block title %}{% endblock %}</title>
85 <h1>{{ block('title') }}</h1>
86 {% block body %}{% endblock %}
91 It's possible to render the contents of the parent block by using the
93 the parent block:
95 .. code-block:: jinja
97 {% block sidebar %}
106 Twig allows you to put the name of the block after the end tag for better
109 .. code-block:: jinja
111 {% block sidebar %}
112 {% block inner_sidebar %}
117 Of course, the name after the ``endblock`` word must match the block name.
125 .. code-block:: jinja
128 <li>{% block loop_item %}{{ item }}{% endblock %}</li>
137 .. code-block:: jinja
139 {% block title %}
143 .. code-block:: jinja
145 {% block title page_title|title %}
152 .. code-block:: jinja
175 .. code-block:: jinja
185 .. code-block:: jinja
196 A block provides a way to change how a certain part of a template is rendered
199 Let's take the following example to illustrate how a block works and more
202 .. code-block:: jinja
207 {% block post %}
214 without the ``block`` tag. The ``block`` inside the ``for`` loop is just a way
217 .. code-block:: jinja
223 {% block post %}
230 Now, when rendering the child template, the loop is going to use the block
234 .. code-block:: jinja
243 Let's take another example: a block included within an ``if`` statement:
245 .. code-block:: jinja
248 {% block head %}
255 Contrary to what you might think, this template does not define a block
262 .. code-block:: jinja
264 {% block head %}
272 .. seealso:: :doc:`block<../functions/block>`, :doc:`block<../tags/block>`, :doc:`parent<../functio…