-
-
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
Add custom stimulus tag to make it easier to create stimuli in django… #60
base: master
Are you sure you want to change the base?
Add custom stimulus tag to make it easier to create stimuli in django… #60
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm especially interested in the validation for this! It would also be great if you could write some unittests for this, since this will be user facing. This such a small component that unittests are perfectly suitable for this.
And thanks for taking the time for this!
""" | ||
# TODO Validate that the reflex is present and can be handled | ||
data = ' '.join([f'data-{key}="{val}"' for key, val in kwargs.items()]) | ||
return mark_safe(f'data-reflex="click->{reflex}" {data}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two comments here
- You can trigger a reflex on a lot of different actions besides
click
. This is one example on the extreme end."cable-ready:after-morph@document->chat#scroll"
(see https://sockpuppet.argpar.se/patterns#capture-all-dom-update-events). - Do we need mark_safe here? If the developer for whatever reason decides to put user data in this template tag and that user data happens to be a script. I'd rather see some broken html than open it up to a XSS attack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though I think having click as a 'default' action is perfectly fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonathan-s these are both cood comments. I used click as its the most "natural" one. But agree that it would be cool to have another method to enter that.
To your seccond command.. we need it at least for the double-ticks (") otherwise they would be escaped. But I agree that it would be better to "safify" the value parts. Do you agree with that approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added several tests now. Do you agree with them?
… templates.
Type of PR (feature, enhancement, bug fix, etc.)
feature
Description
See #59
Why should this be added
Makes it easier to use.
Checklist