Skip to content

Commit 647f5f5

Browse files
committed
[TwigComponent] Document about unwanted behavior with ExposeInTemplate and computed methods
1 parent dec3eb3 commit 647f5f5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/TwigComponent/doc/index.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ use the full path of the template where the macro is defined:
382382
<twig:Alert>
383383
{# ❌ this won't work #}
384384
{% from _self import message_formatter %}
385-
385+
386386
{# ✅ this works as expected #}
387387
{% from 'path/of/this/template.html.twig' import message_formatter %}
388388

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

1556+
.. warning::
1557+
1558+
Ensure to not use the ``ExposeInTemplate`` attribute on a computed method,
1559+
otherwise the method will be called twice instead of only once, leading to
1560+
unnecessary overhead and potential performance issues.
1561+
15561562
Events
15571563
------
15581564

0 commit comments

Comments
 (0)