Tera

A powerful Rust template engine inspired by Jinja2 and the Django template language.

Library
Cargo
v2.1.1
4,289stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
76/100Good
Development Activity100
Maintenance52
Community52
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
82/100Excellent
Architecture86
Code Quality85
Innovation74
Learning Curve82

Tera is a template engine for Rust inspired by Jinja2 and the Django template language. It brings a familiar, expressive templating syntax (blocks, inheritance, loops, macros, filters, and tests) to Rust for rendering HTML pages, emails, config files, and any other text output.

With values passed in through a serde-backed Context, automatic HTML escaping, template inheritance, and an extensible library of built-in filters and functions, Tera is one of the most widely used templating solutions in the Rust ecosystem and powers static site generators and web frameworks alike.

What You Get

  • A Jinja2/Django-inspired templating syntax with variables, conditionals, loops, and comments
  • Template inheritance through blocks plus reusable macros and includes for DRY templates
  • A large library of built-in filters, functions, and tests, all extensible with custom Rust implementations
  • A serde-backed Context so any Serialize value can be passed into templates
  • Automatic, extension-aware HTML autoescaping to help prevent injection in rendered output

Common Use Cases

  • Rendering server-side HTML pages in Rust web applications
  • Generating static site pages (Tera powers the Zola static site generator)
  • Producing emails, reports, or configuration files from templates and structured data
  • Building dynamic text output with custom filters and functions registered from Rust

Under The Hood

Architecture - Tera is the primary crate in a small workspace (alongside tera-contrib). Its src tree separates concerns cleanly: a parsing module turns template source into an AST, a vm module executes that AST to produce output, and dedicated modules provide filters.rs, functions.rs, context.rs, template.rs, and the top-level tera.rs orchestrator. Value handling and error reporting live in their own value/ and reporting.rs modules.

Tech Stack - Pure Rust (edition 2024) with serde as the only required dependency. Numerous optional features pull in indexmap, walkdir, globset, unicode-segmentation, ahash (fast_hash), itoa, and pulldown-cmark-escape to enable directory globbing, faster hashing, and markdown escaping without bloating the default build.

Code Quality - The crate is mature and actively developed, with an in-tree test module, snapshot_tests, and a v2 release accompanied by a migration guide. The modular parsing/vm split and feature-gated optional dependencies reflect a well-factored, maintained codebase.

API Design - The public API is compact and ergonomic: build a Context, call Tera::new to load a directory of templates or one_off for a single render, and register custom filters/functions as closures. The templating language itself will feel immediately familiar to anyone who has used Jinja2 or Django, keeping the learning curve gentle, with a migration guide easing the jump from v1 to v2.

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