htpy-htmx
htpy-htmx is a library to make it easier to work with htmx in htpy.
This library is intended to work with htmx 4.
Note: This project is still a work in progress and there may be breaking changes.
Usage
You can import htpy-htmx as htpy_htmx.hx. All normal htmx attributes are available from the module,
but without the "hx-" prefix. So hx-get="url" would become hx.get("url").
Some htmx extension attributes are available in the htpy_htmx.ext module.
import htpy as h
from htpy_htmx import hx
from htpy_htmx import ext
# pass htmx attributes as functions
h.div("#div-id", hx.get("/some-url/"), hx.trigger("click"))
# hx-partial is also available as a htpy element
h.div("#div-id")[
h.h2["header"],
hx.partial("#part-id", hx.target("#some-element"))[
h.div("#div1")[
h.p["part one"]
]
],
]
h.div(
# trigger allows a list of trigger events
hx.trigger("blur", "keyup[key=='Enter']"),
# swap takes a swap style as string and modifiers as keyword arguments
hx.swap("before", swap="1s", scroll="bottom"),
# hx-on takes an event and a JavaScript expression
hx.on("htmx:before:request", "showSpinner()"),
# vals takes a dict of data.
# To evaluate JavaScript, wrap your js expression in hx.JS() and pass js=True.
hx.vals({"foo": "bar", "some_js": hx.JS("getSomeData()")}, js=True),
)
# to enable inheritance pass inherited=True to a hx-function
h.div(hx.confirm("Are you sure?", inherited=True))[
h.button(hx.delete("/account"))["Delete My Account"],
h.button(hx.put("/account"))["Update My Account"],
]
# Some extension attributes are available in ext:
h.div(
ext.preload("touchstart"),
ext.pending("#msg-opt"),
ext.ws(connect="click"),
)
Installation
To install with pip run:
pip install htpy-htmx
Metadata
Release files for htpy-htmx 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| htpy_htmx-0.1.1.tar.gz | 97.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| htpy_htmx-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 105.4 kB
Release files / htpy_htmx-0.1.1.tar.gz
| Download URL | htpy_htmx-0.1.1.tar.gz |
|---|---|
| Size | 97.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04da085d4a12f473be84c6022586195781508f09df4a1b87c381e3bdad42a6ae
|
|
BLAKE2b-256 checksum How to use checksums |
c4b19b2550461159875f568c6f5e9bb6a44c4c563c50d9ca73da14d49a4febe2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / htpy_htmx-0.1.1-py3-none-any.whl
| Download URL | htpy_htmx-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0784457dbdd802c0adcbcca51380a1351aae2c734dfda654d73980597e4cecd5
|
|
BLAKE2b-256 checksum How to use checksums |
0c879faa0014678fc715971e27b7f62d08eeab4d083588c6192af3acce4022a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|