Askama

A type-safe Jinja-like template engine for Rust that compiles templates into native Rust code at build time.

Library
Cargo
v0.16.0
1,174stars
MIT OR Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
73/100Good
Development Activity72
Maintenance76
Community60
Maturity44
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
83/100Excellent
Architecture90
Code Quality88
Innovation85
Learning Curve70

Askama is a template rendering engine for Rust, based on the Jinja syntax, that generates type-safe Rust code from your templates at compile time. Instead of parsing templates at runtime, it uses a Template derive macro to turn a template file into rendering code bound to a user-defined struct that holds the context.

Because templates are compiled into your crate, Askama catches template errors and type mismatches at build time and delivers near-optimal runtime performance. It supports the familiar Jinja feature set — template inheritance, loops, conditionals, includes, macros, and filters — while working on stable Rust and enforcing UTF-8 correctness.

What You Get

  • A Template derive macro that compiles templates into type-safe Rust code
  • Familiar Jinja-style syntax with inheritance, loops, conditionals, includes, and macros
  • Compile-time error checking against your context struct
  • Built-in escaping (including HTML) and a library of filters
  • Near-zero runtime overhead since templates are compiled into your binary

Common Use Cases

  • Rendering HTML pages in Rust web applications
  • Generating type-checked text output such as emails or config files
  • Producing source code or other structured text from templates
  • Building server-rendered views with compile-time safety guarantees

Under The Hood

Architecture - Askama is a Cargo workspace split into focused crates: askama is the runtime/public crate exposing the Template trait, escaping (html.rs), filters, and helpers; askama_parser parses template syntax into an AST (expr.rs, node.rs, target.rs); and askama_derive/askama_macros implement the #[derive(Template)] procedural macro, whose generator/ emits Rust rendering code, with heritage.rs handling template inheritance and config.rs reading configuration. At compile time the derive reads the template, the parser builds the AST, and the generator produces a Template impl bound to the annotated struct’s fields.

Tech Stack - Pure Rust (edition 2024, MSRV 1.88), organized as a multi-crate workspace. Minimal runtime dependencies (itoa for integer formatting; optional serde/serde_json, percent-encoding behind features). The heavy lifting lives in the proc-macro crates, keeping the runtime crate lean.

Code Quality - The project is mature and actively maintained, with dedicated testing, testing-alloc, testing-no-std, and testing-renamed crates plus a fuzzing harness, clippy lint tests, and a typos config. Concerns are cleanly separated across the parser, derive, and runtime crates, and the codebase supports no_std configurations.

API Design - The public API is deliberately tiny: derive Template, implement/get render(). This declarative surface keeps boilerplate minimal, and the Jinja-like syntax is instantly familiar to anyone from Python or web backgrounds. A dedicated book, an online playground, and docs.rs coverage make the learning curve gentle, though understanding compile-time errors and configuration takes some ramp-up.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search