Maud

A compile-time HTML template engine for Rust, implemented as an html! macro that compiles markup to specialized code.

Library
Cargo
v0.27.0
2,625stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
52/100Fair
Development Activity24
Maintenance24
Community60
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
84/100Excellent
Architecture88
Code Quality84
Innovation86
Learning Curve78

Maud is an HTML template engine for Rust implemented entirely as a procedural macro, html!. Instead of parsing templates at runtime, it compiles your markup directly into specialized Rust code during compilation, producing output that is exceptionally fast and fully type-checked.

Because templates are ordinary Rust code, you get the compiler’s guarantees for free: interpolated values are automatically HTML-escaped, mismatched tags are caught at build time, and there is nothing to deploy alongside your binary. Maud integrates cleanly with popular web frameworks like Actix, Rocket, Axum, and Rouille.

What You Get

  • An html! procedural macro that compiles markup to specialized Rust code
  • Automatic HTML escaping of interpolated values to prevent injection
  • Compile-time checking of tag structure and template correctness
  • A concise syntax for elements, attributes, classes, and control flow
  • Integrations with Actix, Rocket, Axum, Rouille, and other frameworks

Common Use Cases

  • Rendering server-side HTML pages and partials in Rust web apps
  • Building type-safe, reusable view components as Rust functions
  • Generating HTML fragments for htmx-style or SSR responses
  • Producing static HTML output from Rust programs and tooling

Under The Hood

Architecture - The workspace splits into two crates: maud, the public runtime crate exposing the Markup/PreEscaped types and framework integrations, and maud_macros, the proc-macro crate that parses the html! DSL and emits code. At compile time the macro tokenizes the markup, validates structure, and generates a sequence of push_str/escaping calls that write into a String buffer, so there is no runtime template parsing or interpretation.

Tech Stack - Pure Rust built on the procedural-macro system (syn/proc-macro machinery). It offers optional Cargo features to enable integrations with specific web frameworks and ships doctests and a dedicated docs/ book.

Code Quality - A mature project (started 2014) with 65 contributors, CI, a maintained CHANGELOG, a documented release process, and a doctest crate plus book-sourced docs. The compile-to-code strategy means many classes of template errors become compile errors.

API Design - The DSL is deliberately small and readable — nested braces mirror HTML structure, @if/@for express control flow, and Rust expressions interpolate directly — while remaining ordinary Rust. Returning Markup from framework handlers requires little boilerplate, and escaping is automatic by default.

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