Skip to content

[Docs][Stimulus] use camelCase for target naming #1910

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

Merged
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
14 changes: 7 additions & 7 deletions src/StimulusBundle/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -337,32 +337,32 @@ For example:

.. code-block:: html+twig

<div {{ stimulus_target('controller', 'a-target') }}>Hello</div>
<div {{ stimulus_target('controller', 'a-target second-target') }}>Hello</div>
<div {{ stimulus_target('controller', 'myTarget') }}>Hello</div>
<div {{ stimulus_target('controller', 'myTarget secondTarget') }}>Hello</div>

<!-- would render -->
<div data-controller-target="a-target">Hello</div>
<div data-controller-target="a-target second-target">Hello</div>
<div data-controller-target="myTarget">Hello</div>
<div data-controller-target="myTarget secondTarget">Hello</div>

If you have multiple targets on the same element, you can chain them as there's
also a ``stimulus_target`` filter:

.. code-block:: html+twig

<div {{ stimulus_target('controller', 'a-target')|stimulus_target('other-controller', 'another-target') }}>
<div {{ stimulus_target('controller', 'myTarget')|stimulus_target('other-controller', 'anotherTarget') }}>
Hello
</div>

<!-- would render -->
<div data-controller-target="a-target" data-other-controller-target="another-target">
<div data-controller-target="myTarget" data-other-controller-target="anotherTarget">
Hello
</div>

You can also retrieve the generated attributes as an array, which can be helpful e.g. for forms:

.. code-block:: twig

{{ form_row(form.password, { attr: stimulus_target('hello-controller', 'a-target').toArray() }) }}
{{ form_row(form.password, { attr: stimulus_target('hello-controller', 'myTarget').toArray() }) }}

.. _configuration:

Expand Down