Skip to main content

Stimulus alias processor for PJX

Project description

pjx-stimulus

Stimulus extension for PJX.

This package provides StimulusExtension, which adds Stimulus-friendly aliases like stimulus:controller and stimulus:target to PJX templates, and injects the Stimulus browser script on full HTML pages. Install it directly, or use pjx[stimulus].

Installation

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

What It Adds

  • stimulus:controller="dropdown" -> data-controller="dropdown"
  • stimulus:action="click->dropdown#toggle" -> data-action="click->dropdown#toggle"
  • stimulus:target="menu" -> data-dropdown-target="menu"
  • stimulus:value-name="foo" -> data-dropdown-name-value="foo"

The processor tracks active controllers so target, value, class, and outlet aliases resolve to the correct data-* attribute.

Example

<div stimulus:controller="dropdown">
  <button stimulus:action="click->dropdown#toggle">Menu</button>
  <div stimulus:target="menu">Content</div>
</div>

Compiles to:

<div data-controller="dropdown">
  <button data-action="click->dropdown#toggle">Menu</button>
  <div data-dropdown-target="menu">Content</div>
</div>

Extension

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

[project.entry-points."pjx.extensions"]
stimulus = "pjx_stimulus.extension:StimulusExtension"

You can also register it explicitly:

from pjx import PJXEnvironment
from pjx_stimulus.extension import StimulusExtension

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

Browser Asset Injection

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

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

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_stimulus-0.1.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

pjx_stimulus-0.1.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pjx_stimulus-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bcf6ad76758ac1d0eacc39c6ce8fc8e62ab732f0e2eedf2f25d463caee748352
MD5 b09010732b6de2224e7c36b02d8bd5e3
BLAKE2b-256 446f58e99208e36d933aed0f4fe5c2ab0a9588607820b5acb1bbfde5acd47cec

See more details on using hashes here.

Provenance

The following attestation bundles were made for pjx_stimulus-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_stimulus-0.1.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for pjx_stimulus-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c502049ac2043c5f4c2dd56d0ed1e23d9154c40fd78f0023a15472a025785bd7
MD5 61c22ef6e0ac7db5313b72a20da72ee3
BLAKE2b-256 8525f1c4cfc88bc6e9e51fc8cd763aa91463248fb58cb44649ab1fe0a7b5eae7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pjx_stimulus-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