Skip to main content

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.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for htpy-htmx 0.1.3
File Size Uploaded Provenance Actions
htpy_htmx-0.1.3.tar.gz 86.6 kB Without provenance Details for htpy_htmx-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for htpy-htmx 0.1.3
File Interpreter ABI Platform Actions
htpy_htmx-0.1.3-py3-none-any.whl Python 3 none any Details for htpy_htmx-0.1.3-py3-none-any.whl

Total release size: 95.2 kB

Release files / htpy_htmx-0.1.3.tar.gz

Download URL htpy_htmx-0.1.3.tar.gz
Size 86.6 kB
Tags Source
SHA-256 checksum
How to use checksums
922d7b3c5c60579e067c5172c2e73526a5c9a2c5e4332a47bec36dcab79a8a3f
BLAKE2b-256 checksum
How to use checksums
aba79b8fdbe5cf7a742cf4f4e1d9be1c62c8e589c169ee3ccd38ec3aa5922811
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Release files / htpy_htmx-0.1.3-py3-none-any.whl

Download URL htpy_htmx-0.1.3-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef4ffc8c75ccd55e29ac4be495714c949fb5e97b62b3dd85f09a4067a0fb1bea
BLAKE2b-256 checksum
How to use checksums
06d076da2714a52ee8739b6082728bb74c074e403036d33e1688c6393feb885b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Security for htpy-htmx 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page