Skip to content

Add a note about using raw data attributes as a prefered way #10

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

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 18 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ Use the Twig functions from this bundle to activate your controllers:
...
</div>

<!-- would render -->
<div data-controller="hello">
...
</div>

That's it! Whenever this element appears on the page, the ``hello`` controller
will activate.

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

.. note::

Though this bundle provides these helpful functions/filters, it's recommended to
use raw data attributes instead. If you use PhpStorm - you may want to install
[Stimulus plugin](https://plugins.jetbrains.com/plugin/18940-stimulus) that will
bring you nice autocompletion for them.

stimulus_controller
~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -243,6 +255,12 @@ there's also a ``stimulus_controller`` filter:
Hello
</div>

<!-- would render -->
<div data-controller="chart other-controller" data-chart-name-value="Likes">
Hello
</div>


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

.. code-block:: twig
Expand Down