mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 11:27:00 +00:00
add named macro end-tag documentation
This commit is contained in:
@@ -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>`
|
||||||
|
|||||||
Reference in New Issue
Block a user