-
Notifications
You must be signed in to change notification settings - Fork 106
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
Underscore as an attribute is not rendered - used with htmx/hyperscript #193
Comments
Works if you do this:
|
This is actually from here, as a way to allow leading underscores to attribute names that would otherwise collide with Python reserved words. |
Ah I see, should be straightforward to change it to leave it if it is just the "_" and remove if it is "_something"? I'm switching to Dominate from Jinja templates, and its a good deal faster and cleaner for me. |
Regarding how Dominate handles the hyphen and underscore generally. If I add an attribute with an underscore, when is it converted to a hyphen. I see that data_something will convert to data-something at render. This is important for htmx as it uses hx- for all its attributes. EDIT:
I could just fork Dominate and add 'hx_' in here as well I suppose. |
yes, |
Adding # Workaround for dash
special_prefix = any([attribute.startswith(x) for x in ('data_', 'aria_', 'hx_')])
if attribute in set(['http_equiv']) or special_prefix:
attribute = attribute.replace('_', '-').lower() handle: input(
placeholder="Begin typing to search",
name="search",
hx_post=url("search", 1),
hx_trigger="load, input changed delay:500ms, search",
hx_target=f"#{id}",
hx_headers=csrf_header(request),
), |
How is that going, if it's an open source project, please live a link. |
Hi, I encountered similar issue with htmx tags, it may be interesting to add the tags that begin with hx_ to the special prefixes. |
When trying to generate html that uses hyperscript in my htmx webapp Dominate does not allow me to use _ as an attribute for a tag.
I assume its something to do with Python as typically we'd ignore named variables when they are underscores.
Although this just seems to be a convention and not a hard coded language feature.
The text was updated successfully, but these errors were encountered: