Metadata-Version: 2.4
Name: python-fragments
Version: 0.8
Summary: Modern HTML template rendering in Python
Author-email: The Running Algorithm <services@therunningalgorithm.info>
License: Proprietary
Requires-Python: >=3.12
Description-Content-Type: text/markdown
Provides-Extra: lsp
Requires-Dist: basedpyright>=1.39.0; extra == "lsp"
Requires-Dist: lsprotocol>=2025.0.0; extra == "lsp"
Provides-Extra: dev
Requires-Dist: pytest>=8.4.1; extra == "dev"

# 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.

```python
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

```bash
pip install python-fragments
```

Register the loader at your application's entry point, before importing any modules that contain fragments:

```python
from fragments import loader  # isort: skip
```

Any `.py` file containing `<>` is transpiled automatically. Nothing else to configure.
