Skip to content

Commit

Permalink
[TwigComponent] Document about unwanted behavior with ExposeInTemplat…
Browse files Browse the repository at this point in the history
…e and computed methods
  • Loading branch information
Kocal committed Dec 19, 2024
1 parent dec3eb3 commit 647f5f5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/TwigComponent/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ use the full path of the template where the macro is defined:
<twig:Alert>
{# ❌ this won't work #}
{% from _self import message_formatter %}

{# ✅ this works as expected #}
{% from 'path/of/this/template.html.twig' import message_formatter %}

Expand Down Expand Up @@ -1553,6 +1553,12 @@ are called additional times, the cached value is used.
Computed methods only work for component methods with no required
arguments.

.. warning::

Ensure to not use the ``ExposeInTemplate`` attribute on a computed method,
otherwise the method will be called twice instead of only once, leading to
unnecessary overhead and potential performance issues.

Events
------

Expand Down

0 comments on commit 647f5f5

Please sign in to comment.