Rat docs

Documentation

Build with Rat

Rat is a small dialect for writing web apps where a single .rat file declares its state, its markup, and its behaviour. Every page below pairs a description, the canonical snippet, and a live preview of what the snippet renders.

New here? Start with Setup and read straight through — each page assumes the previous one.

Basics

Install the binary, write your first page, and learn the dialect from the ground up. Every page assumes the previous one — read it linearly.

Pages

How filesystem layout under pages/ becomes routes, and how main.rat wraps every page in a shared shell.

Styling

Inline > [selector] blocks for component-local CSS and files under styles/ for globals — both share the same [bracket] variable rewrite.

Builtins

Top-level callables — logging, inspection, strings, math, conversion, collections, encoding, HTTP — that work identically on server tier and inside browser handlers.

Namespaces

Dotted stdlib surfaces — json, date, regex — with the same location-transparent dispatch as builtins.

Data

Declare models under data/, register databases, and call queries through the unified namespace dispatch.

API

JSON endpoints from .rat files under api/ — plain function calls over HTTP with explicit opt-in for what crosses the network.

Forms and uploads

Two-way input bindings, handler-driven submission, and the multipart upload surface.

Realtime

Server-side broadcast over SSE — pages subscribe with one tag and get live patches.

Dev workflow

The CLI, the settings file, and the hot-reload loop that makes editing feel instant.

Advanced

Cross-runtime dispatch (Python, JS) and middleware services with route patterns and lifecycle hooks.