From 16cd48ae85ad99c5aee8f6554e7c719642448320 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Thu, 19 Dec 2024 23:42:21 +0100 Subject: [PATCH] [TwigComponent] Document about unwanted behavior with ExposeInTemplate and computed methods --- src/TwigComponent/doc/index.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/TwigComponent/doc/index.rst b/src/TwigComponent/doc/index.rst index d933063d1e..f75020196e 100644 --- a/src/TwigComponent/doc/index.rst +++ b/src/TwigComponent/doc/index.rst @@ -382,7 +382,7 @@ use the full path of the template where the macro is defined: {# ❌ this won't work #} {% from _self import message_formatter %} - + {# ✅ this works as expected #} {% from 'path/of/this/template.html.twig' import message_formatter %} @@ -1553,6 +1553,12 @@ are called additional times, the cached value is used. Computed methods only work for component methods with no required arguments. +.. tip:: + + 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 ------