Description
I am currently working on a project in which StimulusJs and Twig components are being used together. I just looked in the documentation, it seems to me that there is no way to add a Stimulus controller using the Stimulus Twig helpers.
<twig:Button
variant="danger"
{{ stimulus_action('controller', 'action') }}
>
Delete
</twig:Button>
It is not possible to add a controller or action like this because only attributes are allowed, which results in an error.
Expected attribute name when parsing the "<twig:Button" syntax.
I could pass the controller or action to the component via a prop, but this would make the components much more complex. Ultimately, we used the stimulus data attributes as a fallback. This means we lose all the benefits of the stimulus twig helper functions.
<twig:Button
variant="danger"
data-action="controller#action"
>
Delete
</twig:Button>
Is there a better way to add these stimulus twig helper functions, or what would be required to allow them?