-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Provide Template Tag to generate data-reflex html attributes #59
Comments
Stimulus also happens to be the name of the front-end framework where it's entirely possible to build an entire UI without once ever referencing the server past the initial page load, so a tag should not be targeted at the subset functionality of this package while being labeled more generally, as that would be confusing. I think it actually makes sense to have a As long as the semantics are right, I love the idea. |
What ultimately gets my knickers in a twist is the possibility of doing something like
Things to ponder
|
Yes, this is the new stimulus 2.0 syntax. The current docs still contain syntax for stimulus 2.0, see #61 |
It's an interesting idea using
However controllers can be nested like this.
From what I can tell the When thinking about this we really have two concepts here that are easy to conflate. We've got stimulus and reflex. They just happen to share some attributes. So it could be wise to separate the two. So if we have a
Then we could have a One of the slightly annoying bits in stimulus2.0 is that there is syntax that looks like this, the data attributes become fairly verbose. https://stimulus.hotwire.dev/reference/values
<div data-controller="loader"
data-loader-url-value="/messages">
</div>
https://stimulus.hotwire.dev/reference/targets
<form data-controller="search checkbox">
<input type="checkbox" data-search-target="projects" data-checkbox-target="input">
<input type="checkbox" data-search-target="messages" data-checkbox-target="input">
…
</form>
https://stimulus.hotwire.dev/reference/css-classes
<form data-controller="search"
data-search-loading-class="search--busy"
data-search-no-results-class="search--empty"
>
# Stimulus and reflexes can also access normal data attributes.
# The data attributes don't belong to any particular controller or reflex.
<div data-hello="world" data-hello2="world">
</div> Personally I'd be happy to limit the current PR for reflex things only to limit the scope. Getting a good solution for the stimulus parts seems to increase the scope quite dramatically. Thoughts on this @DamnedScholar and @JulianFeinauer? |
@jonathan-s I agree with your comment but thats also possible at the moment. In fact, the *_reflex tag can optionally get two list parameters. Then, the first is the controller and the second the method, like that example (from tag_example.html):
If the rexlex is defined INSIDE a This snippet would be similar:
Of cours all of this is undocumented but.. just to give you some context. |
@DamnedScholar I added the possibility to pass a dict to the *_reflex functions which contains information about controller, reflex and parameters. You can see this in the test |
So, when |
@DamnedScholar to clarify... I do this in Django and insert the controller on the reflex (as it's needed). |
I've been thinking on this for a few days and this an alternative and I think this api for the templatetag could work pretty well.
For the stimulus controller itself. I would suggest
I think this hits the balance of giving flexibility while still being less verbose. Plus it's possible to do validation if you are so inclined. It might be that you can't write And just a note, it looks like rails use this as a template tag.
|
Feature Request
Currently reflex attributes have to be hand-craftet inside the templates. A custom tag could help users to get these right.
Is your feature request related to a problem?
No
Describe the solution you'd like
I suggest a template tag like:
{% stimulus 'lazy_load_reflex#increment' count=count increment=1 %}
which would be used in a Template like
and would generate the following HTML (formatted differently)
PR link
#60
The text was updated successfully, but these errors were encountered: