Knio / dominate

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.
GNU Lesser General Public License v3.0
1.72k stars 108 forks source link

Planning to add HTMX support? #181

Closed danilommarano closed 1 year ago

danilommarano commented 1 year ago

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>
Knio commented 1 year ago

See the docs for attribute setting here: https://github.com/Knio/dominate#attributes