Replace your HTML templates with Python server-Side components
Project description
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 (.jinja files) with special metadata comments:
{# def parameter1 parameter2=default_value #}- Defines required and optional parameters{# import "path/to/component.jinja" 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.jinja" 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.jinja", title="Hello", content="This is a card")
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jx-0.6.0.tar.gz.
File metadata
- Download URL: jx-0.6.0.tar.gz
- Upload date:
- Size: 33.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcedbbc338fe174a926b80d68f33be4b391c19465e7403e927805c2a1e1e2923
|
|
| MD5 |
364afcd69447ce717580d3367abd01ab
|
|
| BLAKE2b-256 |
c9057a912512349850c084d49f371ea47a1635b90cf957564c2e5652a60879da
|
File details
Details for the file jx-0.6.0-py3-none-any.whl.
File metadata
- Download URL: jx-0.6.0-py3-none-any.whl
- Upload date:
- Size: 22.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3874758f4d9622116bd6dcd526d68de25000b0e50e36d708a06b5cd61eff1918
|
|
| MD5 |
6af220ce67f2e19e587cdd62649c44bd
|
|
| BLAKE2b-256 |
0dfa7d20b357e75afb7753dc1461d3c63dcd41cec9450e35283ce45ac57bc481
|