Skip to main content

Modern HTML template rendering in Python

Project description

Python Fragments

Tests PyPI version Python versions License Documentation VS Code Extension

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

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 to get started.

VS Code completions demo

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.

Documentation

Full documentation is available at 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 for details.

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

python_fragments-0.35.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

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

python_fragments-0.35-py3-none-any.whl (31.3 kB view details)

Uploaded Python 3

File details

Details for the file python_fragments-0.35.tar.gz.

File metadata

  • Download URL: python_fragments-0.35.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for python_fragments-0.35.tar.gz
Algorithm Hash digest
SHA256 f08f4b8ff3980fa8ebc6b331355907117d972d258012196766644d6f10db8a1d
MD5 23055d8bbf1f71fd641fa797f034597a
BLAKE2b-256 a2592a4e223d4a38ccc9631c8a380ed5497583fd997297bae04d71740ab68acb

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_fragments-0.35.tar.gz:

Publisher: release.yml on TheRunningAlgorithm2/python-fragments

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file python_fragments-0.35-py3-none-any.whl.

File metadata

  • Download URL: python_fragments-0.35-py3-none-any.whl
  • Upload date:
  • Size: 31.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for python_fragments-0.35-py3-none-any.whl
Algorithm Hash digest
SHA256 efdac283fe6666380bd79cf402dcf4f86a8ce76c5718516f3de62a01bd3dbd2c
MD5 79f77cac63e17571de87a27c5b699b10
BLAKE2b-256 a78f46f5f6840efeb3465b60f58c21a5a629edbdcf7810c789a71998c1a9eb08

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_fragments-0.35-py3-none-any.whl:

Publisher: release.yml on TheRunningAlgorithm2/python-fragments

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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