Kida 0.3.0
Terminal rendering mode, framework integrations, sandbox, coverage, a11y linting, formatter, extensions
Released 2026-03-26.
Kida 0.3.0 is a major feature release introducing terminal rendering mode, framework integrations for Flask/Starlette/Django, a sandboxed environment, template coverage, accessibility linting, a template formatter, and an extension/plugin architecture.
Highlights
- Terminal rendering mode —
Environment(autoescape="terminal")enables declarative CLI/TUI output with ANSI-safe escaping, 30+ terminal filters, built-in components, and color depth fallback. - Framework integrations — Drop-in
kida.contribadapters for Flask, Starlette/FastAPI, and Django. - Sandbox —
SandboxedEnvironmentwith configurable security policies for untrusted templates. - Coverage —
CoverageCollectortracks template line execution with LCOV/Cobertura export. - Accessibility linting — Static checks for
img-alt,heading-order,html-lang,input-label. - Template formatter —
kida fmtfor opinionated template formatting. - Extensions — Plugin architecture for custom tags with
Extensionbase class.
Added
Terminal Rendering
autoescape="terminal"— One flag activates terminal mode with ANSI-safe escaping.- 30+ terminal filters — Colors (
fg,bg,bold,dim,italic,underline), layout (table,tree,cols,rule), data (badge,diff,progress,sparkline), and more. - Built-in components —
panel,header,footer,connector,row,cols,rule,banner— all width-aware with truncation safety. WidthStrategy— Configurable character width handling with terminal probe auto-detection, wcwidth support, and East Asian ambiguous width setting.- Color depth fallback —
fg()/bg()degrade gracefully across truecolor, 256-color, basic, and no-color terminals. LiveRenderer— In-place terminal re-rendering withSpinneranimation support.stream_to_terminal()— Progressive chunk-by-chunk terminal output.- Responsive
stack()— Side-by-side when terminal is wide, stacked when narrow. kida renderCLI —kida render template.txt --data context.json [--stream].- Icon/box-drawing sets — Unicode and ASCII degradation with VS15 text presentation selectors.
Framework & Security
kida.contrib.flask— Flask integration adapter.kida.contrib.starlette— Starlette/FastAPI integration adapter.kida.contrib.django— Django template backend.SandboxedEnvironment— Restricts collection methods to read-only by default; call-time safety checking blocks unsafe types;allow_mutating_methodsandallow_callingallowlists.- CSP nonce support —
inject_csp_nonce()andcsp_nonce_filterfor Content Security Policy.
Tooling
CoverageCollector— Tracks template line execution with LCOV and Cobertura output. Thread-safe with module-level locking for concurrent usage.- Accessibility linting —
img-alt,heading-order,html-lang,input-labelchecks. - Template type checker —
{% template %}declarations for context type annotations. - Template formatter —
kida fmtwith configurable blank lines and indentation. - Extension architecture —
Extensionbase class withnode_typesregistration and compiler dispatch via_extension_compilers. - Content stacks/portals —
{% push %}/{% stack %}for CSS/JS aggregation. StreamTransform— Progressive rendering transform for streaming output.- Unified
NodeVisitor/NodeTransformer— MRO-aware dispatch cache.
Changed
- Immutable AST — Frozen-dataclass nodes with structural equality.
RenderContext— Free-threading safe, no shared mutable state.- Exception hierarchy — Extracted to
kida.exceptionswith source-context-aware error classes. - Compiler optimizations — Constant folding, output coalescing, copy-on-write AST transforms, hoisted dispatch tables, compile-time rebinding tracking.
Upgrade Notes
- No breaking template or API changes for existing
render()/get_template()usage. - Terminal mode is opt-in via
autoescape="terminal"orterminal_env(). - Framework adapters are in
kida.contrib— import and configure for your framework. SandboxedEnvironmentis a drop-in replacement forEnvironmentwhen running untrusted templates.