Modern HTML template rendering in Python
Project description
Python Fragments
This package is in early development and not yet stable. The API may change without notice between releases.
Production-ready, modern HTML template rendering in Python — no build step, no template files, and native HTML awareness out of the box.
from fragments import loader # isort: skip
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from components import Layout, PostCard
app = FastAPI()
POSTS = [...]
@app.get("/", response_class=HTMLResponse)
async def index() -> str:
published = [p for p in POSTS if p.published]
return <>
<Layout title="My Blog">
<h1>Latest Posts</h1>
<PostCard for={{ post in published }} post={{ post }} />
</Layout>
</>
Installation
pip install python-fragments
Register the loader at your application's entry point, before importing any modules that contain fragments:
from fragments import loader # isort: skip
Any .py file containing <> is transpiled automatically. Nothing else to configure.
Project details
Release history Release notifications | RSS feed
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 python_fragments-0.12.tar.gz.
File metadata
- Download URL: python_fragments-0.12.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3631d8a2c490f0af9a801d1eb9ef80da1b6089133a054e17d8038a3461ec697
|
|
| MD5 |
472674a1b83d8d8d8b7bc0669c00654c
|
|
| BLAKE2b-256 |
6dde357b8e80a71c643e187549a2d9347dc840c90fb55e2c8a2433fc658afda8
|
Provenance
The following attestation bundles were made for python_fragments-0.12.tar.gz:
Publisher:
release.yml on TheRunningAlgorithm2/python-fragments
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_fragments-0.12.tar.gz -
Subject digest:
b3631d8a2c490f0af9a801d1eb9ef80da1b6089133a054e17d8038a3461ec697 - Sigstore transparency entry: 1629928734
- Sigstore integration time:
-
Permalink:
TheRunningAlgorithm2/python-fragments@5b55fa00ee635e68e9814b2ac4cbf554eab0f4e5 -
Branch / Tag:
refs/tags/v0.12 - Owner: https://github.com/TheRunningAlgorithm2
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5b55fa00ee635e68e9814b2ac4cbf554eab0f4e5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file python_fragments-0.12-py3-none-any.whl.
File metadata
- Download URL: python_fragments-0.12-py3-none-any.whl
- Upload date:
- Size: 28.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce2d8940148063489bd8ec392a310aaa0e29d28ad62c4f4ceec3c157cfb2ffad
|
|
| MD5 |
4741991787852de7fc2b609d8cc82f69
|
|
| BLAKE2b-256 |
bdde6a2d137999011adc7c1323205583ce0c83ab5ca247d0cdbf8ef8fb891612
|
Provenance
The following attestation bundles were made for python_fragments-0.12-py3-none-any.whl:
Publisher:
release.yml on TheRunningAlgorithm2/python-fragments
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_fragments-0.12-py3-none-any.whl -
Subject digest:
ce2d8940148063489bd8ec392a310aaa0e29d28ad62c4f4ceec3c157cfb2ffad - Sigstore transparency entry: 1629928738
- Sigstore integration time:
-
Permalink:
TheRunningAlgorithm2/python-fragments@5b55fa00ee635e68e9814b2ac4cbf554eab0f4e5 -
Branch / Tag:
refs/tags/v0.12 - Owner: https://github.com/TheRunningAlgorithm2
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5b55fa00ee635e68e9814b2ac4cbf554eab0f4e5 -
Trigger Event:
push
-
Statement type: