Skip to content

Commit

Permalink
[Doc] Mention how to work with Twig macros in Twig Components
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz authored and Kocal committed Dec 7, 2024
1 parent 52b64e1 commit 45f825e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/TwigComponent/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,21 @@ You can even give the block default content. See
:ref:`Passing HTML to Components via Block <embedded-components>`
for more info.

The only limitation when defining contents inside a component using the HTML syntax
is that you cannot import macros using the ``_self`` keyword. You must always use
the full template path:

.. code-block:: html+twig

<twig:Alert>
{# ❌ this won't work #}
{% from _self import message_formatter %}
{# ✅ this works as expected #}
{% from 'some/path/template.html.twig' import message_formatter %}

{{ message_formatter('...') }}
</twig:Alert>

Fetching Services
-----------------

Expand Down

0 comments on commit 45f825e

Please sign in to comment.