File tree Expand file tree Collapse file tree 3 files changed +13
-39
lines changed
LiveComponent/src/Resources/doc Expand file tree Collapse file tree 3 files changed +13
-39
lines changed Original file line number Diff line number Diff line change @@ -249,30 +249,15 @@ Component Attributes
249249
250250.. versionadded :: 2.1
251251
252- The `` HasAttributes `` trait was added in TwigComponents 2.1.
252+ Component attributes were added in TwigComponents 2.1.
253253
254254`Component attributes `_ allows you to render your components with extra
255255props that are are converted to html attributes and made available in
256256your component's template as an ``attributes `` variable. When used on
257- live components, these props are persisted between renders. You can enable
258- this feature by having your live component use the ``HasAttributesTrait ``:
257+ live components, these props are persisted between renders.
259258
260- .. code-block :: diff
261-
262- // ...
263- use Symfony\UX\LiveComponent\Attribute\LiveProp;
264- + use Symfony\UX\TwigComponent\HasAttributesTrait;
265-
266- #[AsLiveComponent('random_number')]
267- class RandomNumberComponent
268- {
269- + use HasAttributesTrait;
270-
271- #[LiveProp]
272- public int $min = 0;
273-
274- Now, when rendering your component, you can pass html attributes
275- as props and these will be added to ``attributes ``:
259+ When rendering your component, you can pass html attributes as props and
260+ these will be added to ``attributes ``:
276261
277262.. code-block :: twig
278263
Original file line number Diff line number Diff line change 88
99- Add ` PostMount ` hook component hook to intercept extra props.
1010
11- - Add ` HasAttributesTrait ` for components which makes ` attributes ` variable available
12- in component templates .
11+ - Add attributes system that takes extra props passed to ` component() ` and converts them
12+ into a ` ComponentAttributes ` object available in your template as ` attributes ` .
1313
1414- Add ` PreRenderEvent ` to intercept/manipulate twig template/variables before rendering.
1515
Original file line number Diff line number Diff line change @@ -413,27 +413,16 @@ Component Attributes
413413
414414.. versionadded :: 2.1
415415
416- The `` HasAttributes `` trait was added in TwigComponents 2.1.
416+ Component attributes were added in TwigComponents 2.1.
417417
418418A common need for components is to configure/render attributes for the
419- root node. You can enable this feature by having your component use
420- the ``HasAttributesTrait ``. Attributes are any data passed to ``component() ``
421- that cannot be mounted on the component itself. This extra data is added
422- to a ``ComponentAttributes `` object that lives as a public property on your
423- component (available as ``attributes `` in your component's template).
419+ root node. Attributes are any data passed to ``component() `` that cannot be
420+ mounted on the component itself. This extra data is added to a
421+ ``ComponentAttributes `` that is available as ``attributes `` in your
422+ component's template.
424423
425- To use, add the ``HasAttributesTrait `` to your component:
426-
427- use Symfony\U X\T wigComponent\A ttribute\A sTwigComponent;
428- use Symfony\U X\T wigComponent\H asAttributesTrait;
429-
430- #[AsTwigComponent('my_component')]
431- class MyComponent
432- {
433- use HasAttributesTrait;
434- }
435-
436- Then render the attributes on the root element:
424+ To use, in your component's template, render the ``attributes `` variable in
425+ the root element:
437426
438427.. code-block :: twig
439428
You can’t perform that action at this time.
0 commit comments