Dominate is a Python library for creating and manipulating HTML documents using an elegant DOM API. It allows you to write HTML pages in pure Python very concisely, which eliminate the need to learn another template language, and to take advantage of the more powerful features of Python.
Currently is not possible to write elements with HTMX attributes. This is because every HTMX attribute uses the - character for namespacing, which is not accepted by Python as a variable character.
At HTMX docs there is the following button example:
<script src="https://unpkg.com/htmx.org@1.9.5"></script>
<!-- have a button POST a click via AJAX -->
<button hx-post="/clicked" hx-swap="outerHTML">
Click Me
</button>
But when I tried to simulate it using _ as described in the SVG readme section it didn't work.
from dominate.tags import *
element = button(hx_post="/clicked", hx_swap="outerHTML")
print(element)
# <button hx_post="/clicked" hx_swap="outerHTML"></button>
Currently is not possible to write elements with HTMX attributes. This is because every HTMX attribute uses the
-
character for namespacing, which is not accepted by Python as a variable character.At HTMX docs there is the following button example:
But when I tried to simulate it using
_
as described in the SVG readme section it didn't work.