Skip to main content

Replace your HTML templates with Python server-Side components

Project description

Jx

python: 3.12, 3.13, 3.14 license: MIT

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")

VisualStudio Code extension

If you are using VisualStudio Code, install the Jinja-Jx extension.

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

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

jx-0.8.2.tar.gz (41.4 kB view details)

Uploaded Source

Built Distribution

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

jx-0.8.2-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file jx-0.8.2.tar.gz.

File metadata

  • Download URL: jx-0.8.2.tar.gz
  • Upload date:
  • Size: 41.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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

Hashes for jx-0.8.2.tar.gz
Algorithm Hash digest
SHA256 6f4b3061e6fc7e8ea2824be96d8bf08aa330c430239305129fd71e0fe0d30a26
MD5 db7ef947c6ea3a455cff98a5b59fa21c
BLAKE2b-256 1077e0b194c5518e81cbdcd281954663b55e6450f04558c447bb1a7fa12d2f84

See more details on using hashes here.

File details

Details for the file jx-0.8.2-py3-none-any.whl.

File metadata

  • Download URL: jx-0.8.2-py3-none-any.whl
  • Upload date:
  • Size: 26.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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

Hashes for jx-0.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 feab76dcb2cf825ffbfef7091ac686c5eedede0860dfa555acab563f6cfe74b1
MD5 68ec2ae65dc883e6137e3e291e636a08
BLAKE2b-256 88bf6ad520c286e76cb7debbed0144d38340d5b873dfc1899e5cb83a627aaf2f

See more details on using hashes here.

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