Heyπ I'm exploring ways to integrate htmx with domonic. Although the **{"":""} method works just fine, but it tends to result in spaghetti-like code just like React or Vue π
To avoid this, I've worked around. However, the challenge lies in creating custom elements inherited from base elements for inputs, links, buttons, forms, and perhaps divs each one for each one .
here is an example of my simple cutom button:
from domonic import button
class Button(button):
def __init__(self, text, accent, icon):
super().__init__(text)
self.setAttribute("accent", accent)
def change_accent(self, accent):
self.setAttribute("accent", accent)
def htmx_get(self, url: str):
self.setAttribute("hx-get", url)
def htmx_post(self, url: str):
self.setAttribute("hx-post", url)
def htmx_trigger(self, event: str):
self.setAttribute("hx-trigger", event)
def htmx_target(self, target: str):
self.setAttribute("hx-target", target)
def htmx_swap(self, swap: str):
self.setAttribute("hx-swap", swap)
the question, Is there a way to achieve this without having to inherit from each element and create a custom one?
It would be fantastic if domonic had a built-in htmx functions for buttons, inputs, forms, hrefs, or even divs, similar to the div.html()
For example:
htmx_button = button('some action').htmx_post('/post').htmx_target('.post')
# or like so
htmx_button = button('some action')
htmx_button.set_hxpost("/post")
htmx_button.set_hxtarget(".post")
You get the point.