Metadata-Version: 2.4
Name: pating
Version: 0.1.0
Summary: A general-purpose .paw templating engine (Jinja2 + Alpine + HTMX parity), pure Python, backend agnostic, Bao first.
Project-URL: Homepage, https://github.com/ramil-lina36/pating
Project-URL: Source, https://github.com/ramil-lina36/pating
Author: Ramil
License: MIT
License-File: LICENSE
Keywords: bao,html,pating,paw,server-rendered,templating
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Markup :: HTML
Requires-Python: >=3.10
Requires-Dist: markupsafe>=2.1
Provides-Extra: bao
Provides-Extra: dev
Requires-Dist: pytest>=7.4; extra == 'dev'
Description-Content-Type: text/markdown

# 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

```sh
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

```python
from pating import render

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

Loops, conditionals, filters, whitespace control:

```python
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:

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

## The `.paw` syntax at a glance

```html
{# 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:

```html
<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

- [`docs/USAGE.md`](docs/USAGE.md): standalone rendering, use with FastAPI /
  Django / Flask, the client runtime, and the Bao-first extras.
- [`docs/SPEC.md`](docs/SPEC.md): design and locked decisions.
- [`docs/BUILD_PLAN.md`](docs/BUILD_PLAN.md): the phased plan.
- Runnable [`examples/`](examples/).

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