1 unstable release
| 0.1.0 | Mar 16, 2026 |
|---|
#1167 in Template engine
Used in tsx
35KB
680 lines
forge — 4-tier code generation engine for the tsx Framework Protocol.
Overview
forge is built on Tera and extends it with:
- 4-tier template hierarchy —
Atom → Molecule → Layout → Feature(classified automatically from template paths) - Import hoisting — templates call
{{ "import x from 'x'" | collect_import }}and{{ render_imports() }}at the top of the file to emit a deduplicated import block. - Token-budget metadata — knowledge
.mdfiles carrytoken_estimatein frontmatter so agents can request exactly as much context as they need. - Framework package loading — load templates from disk, embedded bytes, or npm packages.
Quick Start
use forge::{Engine, ForgeContext};
let mut engine = Engine::new();
engine.add_raw("hello.jinja", "Hello {{ name | pascal_case }}!").unwrap();
let ctx = ForgeContext::new().insert("name", "world");
let out = engine.render("hello.jinja", &ctx).unwrap();
assert_eq!(out, "Hello World!");
Dependencies
~6–11MB
~193K SLoC