Metadata-Version: 2.4
Name: python-fragments
Version: 0.33
Summary: Modern HTML template rendering in Python
Author-email: The Running Algorithm <services@therunningalgorithm.info>
License: MIT License
        
        Copyright (c) 2026 The Running Algorithm
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
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"
Dynamic: license-file

# Python Fragments

> **This package is in early development and not yet stable. The API may change without notice between releases.**

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

## IDE Support

Type checking, completions, hover docs, go-to-definition, rename, and semantic highlighting — all working inside fragment syntax.

![VS Code completions demo](docs/assets/vscode.gif)

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

## Feedback and feature requests

Bug reports and feature requests are welcome via [GitHub Issues](https://github.com/TheRunningAlgorithm2/python-fragments/issues). The project is not currently accepting code contributions.
