# Kida

URL: /kida/
Description: A Python template engine and Jinja2 alternative for HTML templates, streaming, and framework integration

---

> For a complete page index, fetch /kida/llms.txt.

## Python Template Engine for Modern Templates

**Jinja2 alternative. AST-native. Streaming-ready.**

Kida is a pure-Python template engine for HTML templates, partials, and reusable
components. It compiles templates directly to Python AST, supports block rendering and
streaming output, and works well as a Jinja2 alternative for Python 3.14+ projects.

```python
from kida import Environment

env = Environment()
template = env.from_string("Hello, {{ name }}!")
print(template.render(name="World"))
# Output: Hello, World!
```

---

## Why Use Kida

:::{cards}
:columns: 2
:gap: medium

:::{card} AST-Native Compilation
:icon: cpu
Compiles templates to `ast.Module` objects directly. No string concatenation, no regex
parsing, no code-generation layer.
:::{/card}

:::{card} Free-Threading Ready
:icon: zap
Built for Python 3.14t (PEP 703). Renders templates concurrently without the GIL. Declares `_Py_mod_gil = 0`.
:::{/card}

:::{card} Modern Syntax
:icon: code
Unified `{% end %}` for all blocks. Pattern matching with `{% match %}`. Pipelines with `|>`. Built-in caching.
:::{/card}

:::{card} Zero Dependencies
:icon: package
Pure Python with no runtime dependencies. Includes native `Markup` class—no markupsafe required.
:::{/card}

:::{/cards}

## Common Use Cases

- Rendering HTML templates for web apps, static sites, and email output
- Replacing or evaluating Jinja2 in Python codebases
- Streaming template output for chunked responses and SSE
- Rendering blocks or regions for HTMX partials and layout composition
- Integrating template analysis and metadata into higher-level frameworks

---

## Performance

StringBuilder rendering for O(n) concatenation:

```python
# Kida: O(n) StringBuilder
_out.append(...)
return "".join(_out)
```

| Template Size | Time |
|---------------|------|
| Small (10 vars) | ~0.3ms |
| Medium (100 vars) | ~2ms |
| Large (1000 vars) | ~15ms |

---

## Zero Dependencies

Kida is pure Python with no runtime dependencies:

```toml
[project]
dependencies = []  # Zero!
```

Includes a native `Markup` class for safe HTML handling—no markupsafe required.

---

## The Bengal Ecosystem

A structured reactive stack — every layer written in pure Python for 3.14t free-threading.

| | | | |
|--:|---|---|---|
| **ᓚᘏᗢ** | [Bengal](https://github.com/lbliii/bengal) | Static site generator | [Docs](https://lbliii.github.io/bengal/) |
| **∿∿** | [Purr](https://github.com/lbliii/purr) | Content runtime | — |
| **⌁⌁** | [Chirp](https://github.com/lbliii/chirp) | Web framework | [Docs](https://lbliii.github.io/chirp/) |
| **=^..^=** | [Pounce](https://github.com/lbliii/pounce) | ASGI server | [Docs](https://lbliii.github.io/pounce/) |
| **)彡** | **Kida** | Template engine ← You are here | [Docs](https://lbliii.github.io/kida/) |
| **ฅᨐฅ** | [Patitas](https://github.com/lbliii/patitas) | Markdown parser | [Docs](https://lbliii.github.io/patitas/) |
| **⌾⌾⌾** | [Rosettes](https://github.com/lbliii/rosettes) | Syntax highlighter | [Docs](https://lbliii.github.io/rosettes/) |

Python-native. Free-threading ready. No npm required.
