Skip to main content

Pating

A general-purpose .paw templating engine. Pure Python, no npm, no Node, no build pipeline. Backend agnostic and usable standalone; Bao first for model-aware components and realtime.

Pating targets parity with Jinja2 (templating), Alpine (client reactivity), and HTMX (server interaction), unified under one .paw syntax. Use it to render web pages, HTML fragments, emails, reports, config files, or plain text.

This is a private, work-in-progress repository. It has no remote.

Install

pip install -e ".[dev]"

Only dependency for the core is markupsafe. The client runtime is a single prebuilt JS file (no build step).

Quick start

from pating import render

html = render("<h1>{title|upper}</h1>", {"title": "hello"})
# '<h1>HELLO</h1>'  (autoescaped by default)

Loops, conditionals, filters, whitespace control:

render(
    "<ul><for u in users><li>{u.name}<if u.admin> (admin)</if></li></for></ul>",
    {"users": [{"name": "Al", "admin": True}, {"name": "Bo", "admin": False}]},
)

Files, includes, and layout inheritance use an Environment with a loader:

from pating import render_file
render_file("templates/page.paw", {"title": "Users", "users": [...]})

The .paw syntax at a glance

{# a comment, dropped from output #}
{expr}                              {# interpolation, HTML-escaped by default #}
{value | filter(arg)}               {# filters, chainable #}
{a if cond else b}                  {# ternary #}

<if cond> ... <elif other> ... <else> ... </if>
<for item in items> ... <else> ... </for>      {# loop helpers: loop.index, .first, .last, .length, .cycle(...) #}
<set name = expr/>

<include "partial.paw">             {# include with current context #}
<include "partial.paw" with={'k': v}>

<extends "layout.paw">              {# layout inheritance #}
<block content> ... {super} ... </block>

<macro card(title, body="")> ... </macro>   {# reusable components #}
<call card("Hi")/>

{x -}   {- y}                       {# whitespace control: trim after / before #}

Client and server directives are plain HTML attributes that the small client runtime interprets in the browser:

<div p-data="{ count: 0 }">
  <button @click="count++">+</button>
  <span p-text="count"></span>
</div>

<button p-get="/items" p-target="#list" p-swap="beforeend">Load more</button>
<div p-sse="/events" p-swap="innerHTML"></div>

Documentation

Status

  • Phase 1 (templating core): production-ready. Full Jinja2-class feature set with a comprehensive test suite.
  • Phase 2 (client reactivity) + Phase 3 (server interaction): the client runtime (src/pating/runtime/pating.js, ~17 KB unminified) and the Python directive builders are complete. The runtime has not yet been exercised by an automated browser test; the Python surface is tested.
  • Phase 4 (Bao-first): complete behind an adapter interface and tested with a fake adapter. Bao is imported lazily and is never required by the core.
  • Phase 5 (packaging/docs/examples): this README, docs/USAGE.md, and examples/.

See the report at the bottom of docs/USAGE.md for known gaps.

Release files for pating 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pating 0.1.0
File Size Uploaded
pating-0.1.0.tar.gz 59.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pating 0.1.0
File Interpreter ABI Platform
pating-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 105.4 kB

Release files / pating-0.1.0.tar.gz

Download URL pating-0.1.0.tar.gz
Size 59.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3638eebba82043e39bdb92c6e5f04ba1bc3680d57780ede79e18a856fdc1cb72
BLAKE2b-256 checksum
How to use checksums
61483f995c35f4c70d285e2b9b7361aee087b07d941916eb07c86d23f0f9b24b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / pating-0.1.0-py3-none-any.whl

Download URL pating-0.1.0-py3-none-any.whl
Size 46.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bcbfae89b65abde44e048db4f1c296d3f67fe89911990190b6d40e6105a91198
BLAKE2b-256 checksum
How to use checksums
e0dc267cbc7121f2252744d4b8c474ae64ee5011dbe6b794458327f736d48531
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page