add named macro end-tag documentation

This commit is contained in:
JakeFr
2016-06-21 11:36:37 +02:00
committed by GitHub
parent 68620b32e4
commit dcc5f450de
+17
View File
@@ -31,6 +31,9 @@ variables.
You can pass the whole context as an argument by using the special You can pass the whole context as an argument by using the special
``_context`` variable. ``_context`` variable.
Import
------
Macros can be defined in any template, and need to be "imported" before being Macros can be defined in any template, and need to be "imported" before being
used (see the documentation for the :doc:`import<../tags/import>` tag for more used (see the documentation for the :doc:`import<../tags/import>` tag for more
information): information):
@@ -83,4 +86,18 @@ import it locally:
</div> </div>
{% endmacro %} {% endmacro %}
Named Macro End-Tags
--------------------
Twig allows you to put the name of the macro after the end tag for better
readability:
.. code-block:: jinja
{% macro input() %}
...
{% endmacro input %}
Of course, the name after the ``endmacro`` word must match the macro name.
.. seealso:: :doc:`from<../tags/from>`, :doc:`import<../tags/import>` .. seealso:: :doc:`from<../tags/from>`, :doc:`import<../tags/import>`