Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc] Minor syntax fix in Twig Components docs #2021

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions src/TwigComponent/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1004,46 +1004,46 @@ You can take full control over the attributes that are rendered by using the

There are a few important things to know about using ``render()``:

1. You need to be sure to call your ``render()`` methods before calling ``{{ attributes }}`` or some
#. You need to be sure to call your ``render()`` methods before calling ``{{ attributes }}`` or some
attributes could be rendered twice. For instance:

.. code-block:: html+twig
.. code-block:: html+twig

{# templates/components/MyComponent.html.twig #}
<div
{{ attributes }} {# called before style is rendered #}
style="{{ attributes.render('style') }} display:block;"
>
My Component!
</div>
{# templates/components/MyComponent.html.twig #}
<div
{{ attributes }} {# called before style is rendered #}
style="{{ attributes.render('style') }} display:block;"
>
My Component!
</div>

{# render component #}
{{ component('MyComponent', { style: 'color:red;' }) }}
{# render component #}
{{ component('MyComponent', { style: 'color:red;' }) }}

{# renders as: #}
<div style="color:red;" style="color:red; display:block;"> {# style is rendered twice! #}
My Component!
</div>
{# renders as: #}
<div style="color:red;" style="color:red; display:block;"> {# style is rendered twice! #}
My Component!
</div>

2. If you add an attribute without calling ``render()``, it will be rendered twice. For instance:
#. If you add an attribute without calling ``render()``, it will be rendered twice. For instance:

.. code-block:: html+twig
.. code-block:: html+twig

{# templates/components/MyComponent.html.twig #}
<div
style="display:block;" {# not calling attributes.render('style') #}
{{ attributes }}
>
My Component!
</div>
{# templates/components/MyComponent.html.twig #}
<div
style="display:block;" {# not calling attributes.render('style') #}
{{ attributes }}
>
My Component!
</div>

{# render component #}
{{ component('MyComponent', { style: 'color:red;' }) }}
{# render component #}
{{ component('MyComponent', { style: 'color:red;' }) }}

{# renders as: #}
<div style="display:block;" style="color:red;"> {# style is rendered twice! #}
My Component!
</div>
{# renders as: #}
<div style="display:block;" style="color:red;"> {# style is rendered twice! #}
My Component!
</div>

Only
~~~~
Expand Down