Skip to content

Commit 80adb89

Browse files
committed
Update docs about Twig & package naming
1 parent d2214ec commit 80adb89

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

bundles/best_practices.rst

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -604,20 +604,30 @@ to the ``peerDependencies``:
604604
605605
In this case, the file located at ``[assets directory]/dist/controller.js`` will be exposed.
606606

607-
If the bundle is named ``acme/feature``, the base key for the controller will be ``acme--feature--slug``: it's composed
608-
of the bundle name and the controller name defined in the ``package.json`` file.
609-
610607
To use it in a template (e.g. one defined in your bundle) you can use it like this:
611608

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

614611
<div
615-
data-controller="acme--feature--slug"
616-
data-acme--feature--slug-modal-value="my-value"
612+
{{ stimulus_controller('acme/feature/slug', { modal: 'my-value' }) }}
613+
{#
614+
will render:
615+
data-controller="acme--feature--slug"
616+
data-acme--feature--slug-modal-value="my-value"
617+
#}
617618
>
618619
...
619620
</div>
620621

622+
Don't forget to add ``symfony/webpack-encore-bundle:^1.12`` as a composer dependency to use
623+
Twig ``stimulus_*`` functions.
624+
625+
.. tip::
626+
627+
If the bundle is named ``acme/feature`` and the controller is named ``slug``, the base key for the controller
628+
will be ``acme/feature/slug``: it's composed of the bundle name and the controller name defined in
629+
the ``package.json`` file.
630+
621631
Learn more
622632
----------
623633

0 commit comments

Comments
 (0)