Closed avila-gabriel closed 5 months ago
Regarding empty attributes have you tried Boolean attributes?
>>> div(data_scroll_into_view=True)
<Element '<div data-scroll-into-view></div>'>
Thanks for opening the issue.
There are a lot of characters in addition to dots that are not valid as python parameters, using the dictionary style is the way to go to deal with it. We do replace with - since is not typically used in HTML while - is not supported in python.
Do you have any ideas for how it could be improved?
I updated the docs slightly in a2af06c04a6fc749f2ee524cd981d3c1b0641471 and 2b7c9541e6905f0aadb8b6ad3d6e3b15a5b48019, I hope that helps make it a bit clearer. Please reopen the issue and/or get back with suggestions on improvements!
Thank you guys for your help. The only thing I can think of would be using double underscores for dots, as its the only python accepted that html don't, but once in data-* attributes which are valid html I have something to share, I'll open a new issue for it #33
Issue: Lack of Support for Empty Attributes and Dots in Attribute Names in htpy
Description
I'm currently integrating the htpy library with the Datastar framework and have encountered issues with how htpy handles HTML attributes. Specifically, htpy does not support:
These features are crucial for working with Datastar as you can see below.
Examples
Current Workaround
I have tried passing attributes as a dictionary to bypass the issue with dots in attribute names, which works fine, although not as delicious as using a parameter. However, this approach does not address the problem with empty attributes, as there is currently no way to include them without assigning a value.
Request
I am seeking a way to enhance htpy's functionality to support both empty attributes and attributes with dots in their names. Any guidance or potential updates to address these issues would be highly appreciated as I'm currently unsure how to proceed without these capabilities. Thank you for looking into this.