-
Notifications
You must be signed in to change notification settings - Fork 54
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
Twig helpers for stimulus vs. "native" syntax #17
Comments
Well, you're right :) But if you're using PhpStorm with Symfony plugin installed and configured - it will help you with autocomplition. And so, it's easier to remember Twig syntax IMO. But it might be subjective, agree. You can use whatever way you like the most (or you can remember better), that's not something super important. If you want to learn more (see more useful examples) so you could compare these 2 ways - I'd recommend you to take a look at the docs: https://github.com/symfony/webpack-encore-bundle#stimulus--symfony-ux-helper Cheers! |
Then it's GREAT because it handles also adding the value attributes, which I honestly can't remember :). So that is a major advantage. And so, for consistency, it makes sense to always recommend using it. Even if you don't have any values initially, you're setup and ready to add them easily later. |
It's: <div data-controller="search" data-search-url-value="..."> ...which looks reasonable to me - it follows Stimulus' logic. Consistency: Never using the Twig helpers is equally consistent as always using them ;-) Anyway, when I come up with a PR for https://github.com/symfony/webpack-encore-bundle#stimulus--symfony-ux-helper, presenting both ways as equal alternatives - will you merge it? |
On https://symfonycasts.com/screencast/stimulus/ajax-html you're using "native" HTML/Stimulus syntax
whereas on previous pages, you're using the Twig helpers, e.g.
{{ stimulus_controller('search-preview') }}
I have a general question: What's the advantage of those Twig helpers at all? At symfony/webpack-encore-bundle#119 (comment), you're saying:
But the Twig syntax needs to be remembered too... ;-)
If there are true advantages, they should be mentioned at https://symfony.com/doc/current/frontend/encore/simple-example.html#stimulus-symfony-ux - and if there aren't, then both syntaxes should be shown (as equivalently "valid" alternatives).
The text was updated successfully, but these errors were encountered: