Skip to content

Commit

Permalink
minor #2062 [DOC] add named macro end-tag documentation (JakeFr)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.x branch.

Discussion
----------

[DOC] add named macro end-tag documentation

Hello!
Just discover endmacro tag supports name, just like block.
But it is not mentionned in the doc.
So here's a PR

Commits
-------

dcc5f45 add named macro end-tag documentation
  • Loading branch information
fabpot committed Aug 15, 2016
2 parents 13b35b8 + dcc5f45 commit 2103977
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions doc/tags/macro.rst
Expand Up @@ -31,6 +31,9 @@ variables.
You can pass the whole context as an argument by using the special
``_context`` variable.

Import
------

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
information):
Expand Down Expand Up @@ -83,4 +86,18 @@ import it locally:
</div>
{% 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>`

0 comments on commit 2103977

Please sign in to comment.