Python server-side components
From chaos to clarity: The power of components in your server-side-rendered Python web app.
How It Works
Jx is a Python library for creating reusable template components with Jinja2. It works by pre-parsing the template source and replacing TitleCased HTML tags with Jinja calls that render the component.
Component Definition
Components are defined as regular Jinja2 templates (.jx files) with special metadata comments:
{# def parameter1 parameter2=default_value #}- Defines required and optional parameters{# import "path/to/component.jx" as ComponentName #}- Imports other components{# css "/path/to/style.css" #}- Includes CSS files{# js "/path/to/script.js" #}- Includes JavaScript files
Example component:
{# def message #}
{# import "button.jx" as Button #}
<div class="greeting">{{ message }}</div>
<Button text="OK" />
Usage Example
from jx import Catalog
# Create a catalog and add a components folder
catalog = Catalog("templates/components")
# Render a component with parameters
html = catalog.render("card.jx", title="Hello", content="This is a card")
VisualStudio Code extension
If you are using VisualStudio Code, install the Jinja-Jx extension.
This extension offers:
- Syntax highlighting of Jx-specific constructs like
import,def,css,js, etc. and PascalCase component tags (e.g.,<MyComponent>) - Add go-to-definition from import paths and component tags to jump to the component file
- Check for syntax errors and validate import paths on save
Metadata
Release files for jx 0.15.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jx-0.15.0.tar.gz | 68.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jx-0.15.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 108.6 kB
Release files / jx-0.15.0.tar.gz
| Download URL | jx-0.15.0.tar.gz |
|---|---|
| Size | 68.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
93390f32fcc0d7959a9672495a0c58348b828abcc4ebfce8e10ae8a9d1c4bf53
|
|
BLAKE2b-256 checksum How to use checksums |
9f1d62b042b71534ebe4868f58228c6a9d6ee5beacbdd70fdfbcb8421e063866
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / jx-0.15.0-py3-none-any.whl
| Download URL | jx-0.15.0-py3-none-any.whl |
|---|---|
| Size | 40.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
934ad4fbb693bfb5de9da13239074829045b11f67803142d96b130042b180a07
|
|
BLAKE2b-256 checksum How to use checksums |
d65c15926ae98aa972ec9bffb739441347dcdcb2600c0207ac0c416761c7f42e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|