Skip to main content

HTMX and SSE alias processor for PJX

Project description

pjx-htmx

HTMX and SSE extension for PJX.

This package provides HTMXExtension, which adds HTMX and SSE attribute aliases to PJX templates and injects the HTMX browser script on full HTML pages. Install it directly, or use pjx[htmx].

Installation

pip install pjx-htmx
# or
pip install pjx[htmx]

What It Adds

  • htmx:post -> hx-post
  • htmx:get -> hx-get
  • htmx:target -> hx-target
  • htmx:swap -> hx-swap
  • sse:connect -> sse-connect
  • sse:swap -> sse-swap

Example

<button htmx:post="/users" htmx:target="#list" htmx:swap="innerHTML">
  Save
</button>

<div sse:connect="/events" sse:swap="message"></div>

Compiles to:

<button hx-post="/users" hx-target="#list" hx-swap="innerHTML">
  Save
</button>

<div sse-connect="/events" sse-swap="message"></div>

Extension

HTMXExtension implements the PJXExtension ABC. It is discovered automatically via the pjx.extensions entry point when the package is installed:

[project.entry-points."pjx.extensions"]
htmx = "pjx_htmx.extension:HTMXExtension"

You can also register it explicitly:

from pjx import PJXEnvironment
from pjx_htmx.extension import HTMXExtension

env = PJXEnvironment(
    loader=FileSystemLoader("templates"),
    extensions=[HTMXExtension()],
)

Browser Asset Injection

On full HTML pages, PJX auto-injects the HTMX browser script when it detects hx-* or sse-* attributes. To vendor the asset locally instead of using a CDN:

pjx assets build static/vendor/pjx --provider htmx

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pjx_htmx-0.1.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pjx_htmx-0.1.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file pjx_htmx-0.1.1.tar.gz.

File metadata

  • Download URL: pjx_htmx-0.1.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pjx_htmx-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7a66b8a421615b96155d0f0f06ac84c6abbeab5850d051ccce53a7e132a8aaa7
MD5 2c590837a2485f99579377286ef3b9e7
BLAKE2b-256 496e9d84620651fbe052ab9e6c8eacd9c3c51a1ab7f43de246a89c057bc88102

See more details on using hashes here.

Provenance

The following attestation bundles were made for pjx_htmx-0.1.1.tar.gz:

Publisher: release.yml on oornnery/pjx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pjx_htmx-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pjx_htmx-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pjx_htmx-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 12548ae9af86e13cd4529e36253f851c0f8eb80774baf8a5d589a55f575222bd
MD5 0991845bc93d4ba8cf94f7008ab8e6ec
BLAKE2b-256 c34981e4a17d345545ae66682c9464d2cb645934ebb2207f1d6a1212511d3da7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pjx_htmx-0.1.1-py3-none-any.whl:

Publisher: release.yml on oornnery/pjx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page