Skip to content

Commit 92228c1

Browse files
authored
Add a note about using raw data attributes as a prefered way
Now with the Stimulus plugin autocomplete in PhpStorm it's better to use raw data attributes instead of built-in functions/filters. Normal Stimulus code is more readable and cleaner IMO.
1 parent 8fe391d commit 92228c1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/StimulusBundle/doc/index.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ Use the Twig functions from this bundle to activate your controllers:
6565
...
6666
</div>
6767

68+
<!-- would render -->
69+
<div data-controller="hello">
70+
...
71+
</div>
72+
6873
That's it! Whenever this element appears on the page, the ``hello`` controller
6974
will activate.
7075

@@ -159,6 +164,13 @@ Stimulus Twig Helpers
159164
This bundle adds 3 Twig functions/filters to help add Stimulus controllers,
160165
actions & targets in your templates.
161166

167+
.. note::
168+
169+
Though this bundle provides these helpful functions/filters, it's recommended to
170+
use raw data attributes instead. If you use PhpStorm - you may want to install
171+
[Stimulus plugin](https://plugins.jetbrains.com/plugin/18940-stimulus) that will
172+
bring you nice autocompletion for them.
173+
162174
stimulus_controller
163175
~~~~~~~~~~~~~~~~~~~
164176

@@ -243,6 +255,11 @@ there's also a ``stimulus_controller`` filter:
243255
Hello
244256
</div>
245257

258+
<!-- would render -->
259+
<div data-controller="chart other-controller" data-chart-name-value="Likes">
260+
Hello
261+
</div>
262+
246263
You can also retrieve the generated attributes as an array, which can be helpful e.g. for forms:
247264

248265
.. code-block:: twig

0 commit comments

Comments
 (0)