Skip to content

[Site] Replace stimulus_* helpers with data-attributes #1517

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
Feb 20, 2024

Conversation

smnandre
Copy link
Member

Fixes #1514 - cc @seb-jean

@weaverryan : I had to adapt a bit the SourceCleaner to keep data-* attributes.

@carsonbot carsonbot added the Status: Needs Review Needs to be reviewed label Feb 18, 2024
@smnandre smnandre changed the title [Site] Replace stimulus_* helper with data-attributes [Site] Replace stimulus_* helpers with data-attributes Feb 18, 2024
@seb-jean
Copy link
Contributor

Great 💯

@carsonbot carsonbot added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Review Needs to be reviewed labels Feb 20, 2024
@weaverryan weaverryan force-pushed the site/remove-stimulus-helpers branch from 79ba4e5 to a32d41e Compare February 20, 2024 15:01
@weaverryan
Copy link
Member

Thanks Simon!

@weaverryan weaverryan merged commit c358863 into symfony:2.x Feb 20, 2024
@CMH-Benny
Copy link

CMH-Benny commented Mar 1, 2024

May I ask what was the motivation of removing those helpers? One could use both notations but one is now just gone?

I used those helpers heavily, because especially the value-api is really verbose. You have to know how to convert the casing, need to put even multiple dashes here and there... It just makes the whole value API now harder to use imho. Not only will I have to refactor many places now, it will raise cognitive load for less afine collegues to parse for the values in the twig code to do adjustements.

Any chance we will get something else back that simplifies it as these helpers did before? @weaverryan @smnandre

@weaverryan
Copy link
Member

I used those helpers heavily, because especially the value-api is really verbose

The helpers are still there in StimulusBundle and won't go away. So if you like them, keep using them. For most cases, I just now prefer to use the raw values attributes and I want to encourage people to give them a try. But sometimes they are a bit complex / ugly. Do whatever you like :)

@CMH-Benny
Copy link

CMH-Benny commented Mar 4, 2024

Oh, thanks for clarifying that! I misread that this is only about the usage of the helpers, but not the helpers themself :D

I mean the helpers are also having their weaknesses, for example I had to merge two controllers with their values applied together, that is also kinda ugly, those cases are easier with the attributes, tho. But especially the values API is really suboptimal to write in an attribute way. Was there alternative ideas about those in the past?

It probably doesn't fit here perfectly, but when we are on that topic - Would it be possible to have the twig parser take care of that and have somthing like this:

<div data-controller="a_controller"
     a_controller#aValueFromThatController="foo" 
     :a_controller#anotherValue="{{ something.number }}"
>
....

Or is this way too complicated?

@smnandre
Copy link
Member Author

smnandre commented Mar 4, 2024

Adding new syntax things can really increase the difficulty (not even talking about maintenance, doc, ..) so i'd like to avoid this.

But i do think some view helper can and should be used in some cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Reviewed Has been reviewed by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Site] Using raw data attributes
5 participants