Metadata-Version: 2.4
Name: python-fragments
Version: 0.36
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.
        
Project-URL: Homepage, https://python-fragments.io
Project-URL: Documentation, https://python-fragments.io
Project-URL: Source, https://github.com/TheRunningAlgorithm2/python-fragments
Project-URL: Issues, https://github.com/TheRunningAlgorithm2/python-fragments/issues
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Markup :: HTML
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

<p align="center">
  <img src="logo.svg" alt="Python Fragments" width="300" />
</p>

<p align="center">
  <a href="https://github.com/TheRunningAlgorithm2/python-fragments/actions/workflows/test.yml"><img src="https://github.com/TheRunningAlgorithm2/python-fragments/actions/workflows/test.yml/badge.svg" alt="Tests" /></a>
  <a href="https://pypi.org/project/python-fragments/"><img src="https://img.shields.io/pypi/v/python-fragments" alt="PyPI version" /></a>
  <a href="https://pypi.org/project/python-fragments/"><img src="https://img.shields.io/pypi/pyversions/python-fragments" alt="Python versions" /></a>
  <a href="https://github.com/TheRunningAlgorithm2/python-fragments/blob/main/LICENSE"><img src="https://img.shields.io/github/license/TheRunningAlgorithm2/python-fragments" alt="License" /></a>
  <a href="https://python-fragments.io"><img src="https://img.shields.io/badge/docs-python--fragments.io-blue" alt="Documentation" /></a>
  <a href="https://marketplace.visualstudio.com/items?itemName=tra-technologies-ltd.python-fragments"><img src="https://img.shields.io/badge/VS%20Code-Extension-blue?logo=visualstudiocode" alt="VS Code Extension" /></a>
</p>

> **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. [Read More](https://python-fragments.io)

```python
from fastapi import APIRouter

router = APIRouter()

@router.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.

Install the [Python Fragments VS Code extension](https://marketplace.visualstudio.com/items?itemName=tra-technologies-ltd.python-fragments) to get started.

![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.

## Documentation

Full documentation is available at [python-fragments.io](https://python-fragments.io).

## Contributing

Bug reports, feature requests, and documentation improvements are all welcome. Code contributions aren't open yet while we work toward v1. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
