Skip to content

Commit 391e250

Browse files
committed
minor #1991 [Doc] Mention that boolean properties require the dynamic syntax (javiereguiluz)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Doc] Mention that boolean properties require the dynamic syntax | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Issues | - | License | MIT This confused me. On Symfony Slack folks mentioned that changing this behavior would be bad for DX (e.g. we can do it in components backend by a PHP class with typed properties but we cannot for anonymous components). So, I think it might be enough to mention this in the docs. Thanks. Commits ------- c9dc8cf [Doc] Mention that boolean properties require the dynamic syntax
2 parents 66bcbca + c9dc8cf commit 391e250

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/TwigComponent/doc/index.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,18 @@ prefix the attribute with ``:`` or use the normal ``{{ }}`` syntax:
295295
// pass object, array, or anything you imagine
296296
<twig:Alert :foo="{col: ['foo', 'oof']}" />
297297

298+
Boolean props require using the dynamic syntax:
299+
300+
.. code-block:: html+twig
301+
302+
{# in this example, the 'false' value is passed as a string
303+
(so it's converted automatically to the true boolean value) #}
304+
<twig:Alert message="..." withCloseButton="false" />
305+
306+
{# in the following examples, the 'false' value is passed as a boolean property #}
307+
<twig:Alert message="..." :withCloseButton="false" />
308+
<twig:Alert message="..." withCloseButton="{{ false }}" />
309+
298310
Don't forget that you can mix and match props with attributes that you
299311
want to render on the root element:
300312

0 commit comments

Comments
 (0)