Skip to content

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

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 1 commit into from
Jan 9, 2024

Conversation

bocharsky-bw
Copy link
Contributor

Q A
Bug fix? no
New feature? no
Issues no
License MIT

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.

@weaverryan
Copy link
Member

I need to check the PR still, but I’m also preferring the direct attributes these days.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should update a bit more, starting with the "Use the Twig functions..." line. Something like:

Then, activate the controller in your HTML:

(show the raw data-controller example).

Then after, something like:

Optionally, this bundle has a Twig function to render the attribute:

(show the stimulus_controller())

.. 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attributes instead, as they're simple enough. If you use...

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stimulus plugin to get nice auto-completion for the attributes

@bocharsky-bw
Copy link
Contributor Author

@weaverryan done! Thanks for the review!


Though this bundle provides these helpful Twig functions/filters, it's
recommended to use raw data attributes instead, as they're simple enough.
If you use PhpStorm IDE - you may want to install
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add this phrase as a tip bloc :)

.. note::

Though this bundle provides these helpful Twig functions/filters, it's
recommended to use raw data attributes instead, as they're simple enough.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps replace « simple enough » with « straight forward » ?

Copy link
Contributor

@94noni 94noni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I second this, it should be the recommended way on doc :)

@bocharsky-bw
Copy link
Contributor Author

@94noni thank you for your review, done!

@weaverryan
Copy link
Member

Thanks Victor!

@weaverryan weaverryan merged commit 1db29a3 into symfony:2.x Jan 9, 2024
@bocharsky-bw bocharsky-bw deleted the patch-2 branch January 9, 2024 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants