2 min read
Python Fragments

Python Fragments is a templating engine that brings modern React-like component syntax directly into Python, without a build system, a compiler step, or any JavaScript tooling in your way.

@router.get("/index")
async def index():
    return <>
        <h1>Hello, World!</h1>
        <div for={{ post in POSTS }} if={{ not post.draft }}>
            <h2>{{ post.title }}</h2>
            <a href={{ f"/posts/{post.slug}" }}>Read More</a>
        </div>
    </>

Fragments is packaged with an LSP, and also provides an official VS Code Extension to make it as easy as possible for users and businesses to get started using it in production.

Why?

I built Fragments as a direct mechanism to improve our development velocity at The Running Algorithm, where we had previously (like many others) been using the somewhat outdated jinja2.