Skip to main content

Tailwind CSS utilities for PJX (cn() class merging)

Project description

pjx-tailwind

Tailwind CSS extension for PJX.

This package provides TailwindExtension, which registers cn() as a Jinja2 global for class-name merging and injects the Tailwind browser build on full HTML pages. Install it directly, or use pjx[tailwind] or pjx[all].

Installation

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

What It Adds

cn() merges class names, filters falsy values, and deduplicates repeated tokens.

Example

---
computed:
  btn_class: cn(
    "btn",
    is_primary and "btn-primary",
    disabled and "opacity-50",
  )
---

<button class={btn_class}>Save</button>

Results:

cn("foo", "bar") -> "foo bar"
cn("base", false, "extra") -> "base extra"
cn("a b", "b c") -> "a b c"

Extension

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

[project.entry-points."pjx.extensions"]
tailwind = "pjx_tailwind.extension:TailwindExtension"

You can also register it explicitly:

from pjx import PJXEnvironment
from pjx_tailwind.extension import TailwindExtension

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

Browser Asset Injection

On full HTML pages, PJX auto-injects the Tailwind browser build when it detects common utility classes or text/tailwindcss. To vendor the asset locally instead of using a CDN:

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

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

Uploaded Source

Built Distribution

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

pjx_tailwind-0.1.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pjx_tailwind-0.1.1.tar.gz
Algorithm Hash digest
SHA256 442374589b08e96c385f79d021c09ca861a29a5aeeea04edcb5a92ea6326c8cc
MD5 2ba732314bc4cefcc64b84017b5f7225
BLAKE2b-256 c340e783371893c57a9c327691d516b656c8455abe9975ef9bb41108d3d2d78c

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for pjx_tailwind-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 10a4cd0f6e18c6e66be320ece27de703877425927f1b48229b0842c268100b02
MD5 ec598893079eb1ee9edde433f5333eee
BLAKE2b-256 a0e934aa24fcf037900e8c21ae16d6de47fd0f145b2209b192dacdf351456262

See more details on using hashes here.

Provenance

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