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

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