Vendored version of askama from crates.io
  • Rust 96.5%
  • HTML 2.8%
  • Python 0.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Guillaume Gomez 229e8bbd16
Some checks failed
CI / Test (windows-latest, stable) (push) Has been cancelled
CI / Package (askama) (push) Has been cancelled
CI / Package (askama_derive) (push) Has been cancelled
CI / Package (askama_escape) (push) Has been cancelled
CI / Package (askama_macros) (push) Has been cancelled
CI / Package (askama_parser) (push) Has been cancelled
CI / Package (bench-build) (push) Has been cancelled
CI / Package (examples/actix-web-app) (push) Has been cancelled
CI / Package (examples/axum-app) (push) Has been cancelled
CI / Package (examples/custom-escaper) (push) Has been cancelled
CI / Package (examples/poem-app) (push) Has been cancelled
CI / Package (examples/rocket-app) (push) Has been cancelled
CI / Package (examples/warp-app) (push) Has been cancelled
CI / Package (fuzzing) (push) Has been cancelled
CI / Package (testing) (push) Has been cancelled
CI / Package (testing-alloc) (push) Has been cancelled
CI / Package (testing-no-std) (push) Has been cancelled
CI / Package (testing-renamed) (push) Has been cancelled
CI / Nightly (askama) (push) Has been cancelled
CI / Nightly (askama_derive) (push) Has been cancelled
CI / Nightly (askama_escape) (push) Has been cancelled
CI / Nightly (askama_macros) (push) Has been cancelled
CI / Nightly (askama_parser) (push) Has been cancelled
CI / Nightly (testing) (push) Has been cancelled
CI / Nightly (testing-alloc) (push) Has been cancelled
CI / Fuzz (all) (push) Has been cancelled
CI / Fuzz (derive) (push) Has been cancelled
CI / Fuzz (filters) (push) Has been cancelled
CI / Fuzz (html) (push) Has been cancelled
CI / Fuzz (parser) (push) Has been cancelled
CI / Cluster-Fuzz (push) Has been cancelled
CI / Docs (askama_derive) (push) Has been cancelled
CI / Docs (askama_escape) (push) Has been cancelled
CI / Docs (askama_macros) (push) Has been cancelled
CI / Docs (askama_parser) (push) Has been cancelled
CI / Audit (push) Has been cancelled
CI / Book (push) Has been cancelled
CI / Typos (push) Has been cancelled
CI / Jinja2-Assumptions (push) Has been cancelled
CI / DevSkim (push) Has been cancelled
CI / Docs (askama) (push) Has been cancelled
CI / Rustfmt (push) Has been cancelled
CI / Check order in Cargo.toml (push) Has been cancelled
CI / Nightly (testing-renamed) (push) Has been cancelled
CI / MSRV (push) Has been cancelled
CI / Nightly (testing-no-std) (push) Has been cancelled
CI / Test (macos-latest, stable) (push) Has been cancelled
CI / Test (ubuntu-latest, beta) (push) Has been cancelled
CI / Test (ubuntu-latest, stable) (push) Has been cancelled
Merge pull request #733 from GuillaumeGomez/update
Update packages version to 0.16.0
2026-04-30 00:46:59 +02:00
.github Add custom escaper example 2026-04-11 13:18:09 +02:00
askama Update packages version to 0.16.0 2026-04-30 00:29:53 +02:00
askama_derive Update packages version to 0.16.0 2026-04-30 00:29:53 +02:00
askama_escape Link to the main branch instead of the master branch 2026-04-11 13:18:09 +02:00
askama_macros Update packages version to 0.16.0 2026-04-30 00:29:53 +02:00
askama_parser Link to the main branch instead of the master branch 2026-04-11 13:18:09 +02:00
bench-build Remove version for askama_macros dependency in bench-build/Cargo.toml 2026-01-27 16:03:52 +01:00
book Add migration guide for 0.15 to 0.16 upgrades 2026-04-30 00:39:48 +02:00
examples Add custom escaper example 2026-04-11 13:18:09 +02:00
fuzzing Limit recursions for Ty generics 2026-03-31 22:49:08 +02:00
testing Merge pull request #730 from GuillaumeGomez/add-err-docs 2026-04-26 17:49:15 +02:00
testing-alloc Simplify versioning in non-published crates (ie tests and examples) 2025-12-29 16:10:59 +01:00
testing-no-std Simplify versioning in non-published crates (ie tests and examples) 2025-12-29 16:10:59 +01:00
testing-renamed Simplify versioning in non-published crates (ie tests and examples) 2025-12-29 16:10:59 +01:00
.gitattributes Switch to std::path::absolute to avoid symlinking template paths (#720) 2026-04-01 17:15:56 +02:00
.gitignore Ignore .DS_Store files 2021-02-05 10:47:35 +01:00
.gitmodules Update fuzzing corpus URL 2025-03-11 20:18:00 +01:00
.readthedocs.yaml Simplify book creation 2025-12-22 18:32:26 +01:00
.rustfmt.toml Don't format with overflow_delimited_expr 2025-02-09 21:45:58 +01:00
_typos.toml Use Parser::[with_]span() to generate proc_macro::Span 2025-08-19 17:41:20 +02:00
Cargo.toml Update packages version to 0.16.0 2026-04-30 00:29:53 +02:00
clippy.toml Switch Rust edition of askama_derive to 2024 2025-07-05 03:21:34 +02:00
deny.toml Update license in deny.toml 2024-11-20 15:00:18 +01:00
LICENSE-APACHE Add license files to each crate (fixes #339) 2020-06-30 12:09:14 +02:00
LICENSE-MIT Add license files to each crate (fixes #339) 2020-06-30 12:09:14 +02:00
README.md Link to the main branch instead of the master branch 2026-04-11 13:18:09 +02:00
tomlfmt.toml Use cargo reference manifest section order 2024-12-13 10:00:48 +01:00

askama

Crates.io GitHub Workflow Status Book docs.rs

Askama implements a template rendering engine based on Jinja, and generates type-safe Rust code from your templates at compile time based on a user-defined struct to hold the template's context.

At some point, Askama got forked into Rinja (explained here) before getting merged back into Askama.

All feedback welcome! Feel free to file bugs, requests for documentation and any other feedback to the issue tracker.

You can find the documentation about our syntax, features, configuration in our book: askama.rs.

Have a look at our Askama Playground, if you want to try out askama's code generation online.

Feature highlights

  • Construct templates using a familiar, easy-to-use syntax
  • Benefit from the safety provided by Rust's type system
  • Template code is compiled into your crate for optimal performance
  • Debugging features to assist you in template development
  • Templates must be valid UTF-8 and produce UTF-8 when rendered
  • Works on stable Rust

Supported in templates

  • Template inheritance
  • Loops, if/else statements and include support
  • Macro support
  • Variables (no mutability allowed)
  • Some built-in filters, and the ability to use your own
  • Whitespace suppressing with '-' markers
  • Opt-out HTML escaping
  • Syntax customization

How to get started

First, add the askama dependency to your crate's Cargo.toml:

cargo add askama

Now create a directory called templates in your crate root. In it, create a file called hello.html, containing the following:

Hello, {{ name }}!

In any Rust file inside your crate, add the following:

use askama::Template; // bring trait in scope

#[derive(Template)] // this will generate the code...
#[template(path = "hello.html")] // using the template in this path, relative
                                 // to the `templates` dir in the crate root
struct HelloTemplate<'a> { // the name of the struct can be anything
    name: &'a str, // the field name should match the variable name
                   // in your template
}

fn main() {
    let hello = HelloTemplate { name: "world" }; // instantiate your struct
    println!("{}", hello.render().unwrap()); // then render it.
}

You should now be able to compile and run this code.