Name Description Size
ascii_str.rs 3738
error.rs 8520
filters
helpers.rs 6344
html.rs 4283
lib.rs [![Crates.io](https://img.shields.io/crates/v/askama?logo=rust&style=flat-square&logoColor=white "Crates.io")](https://crates.io/crates/askama) [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/askama-rs/askama/rust.yml?branch=master&logo=github&style=flat-square&logoColor=white "GitHub Workflow Status")](https://github.com/askama-rs/askama/actions/workflows/rust.yml) [![Book](https://img.shields.io/readthedocs/askama?label=book&logo=readthedocs&style=flat-square&logoColor=white "Book")](https://askama.readthedocs.io/) [![docs.rs](https://img.shields.io/docsrs/askama?logo=docsdotrs&style=flat-square&logoColor=white "docs.rs")](https://docs.rs/askama/) Askama implements a type-safe compiler for Jinja-like templates. It lets you write templates in a Jinja-like syntax, which are linked to a `struct` or an `enum` defining the template context. This is done using a custom derive implementation (implemented in [`askama_derive`](https://crates.io/crates/askama_derive)). For feature highlights and a quick start, please review the [README](https://github.com/askama-rs/askama/blob/master/README.md). You can find the documentation about our syntax, features, configuration in our book: [askama.readthedocs.io](https://askama.readthedocs.io/). # Creating Askama templates The main feature of Askama is the [`Template`] derive macro which reads your template code, so your `struct` or `enum` can implement the [`Template`] trait and [`Display`][std::fmt::Display], type-safe and fast: ```rust # use askama::Template; #[derive(Template)] #[template( ext = "html", source = "<p>© {{ year }} {{ enterprise|upper }}</p>" )] struct Footer<'a> { year: u16, enterprise: &'a str, } assert_eq!( Footer { year: 2025, enterprise: "<em>Askama</em> developers" }.to_string(), "<p>© 2025 &#60;EM&#62;ASKAMA&#60;/EM&#62; DEVELOPERS</p>", ); // In here you see can Askama's auto-escaping. You, the developer, // can easily disable the auto-escaping with the `|safe` filter, // but a malicious user cannot insert e.g. HTML scripts this way. ``` An Askama template is a `struct` or `enum` definition which provides the template context combined with a UTF-8 encoded text file (or inline source). Askama can be used to generate any kind of text-based format. The template file's extension may be used to provide content type hints. A template consists of **text contents**, which are passed through as-is, **expressions**, which get replaced with content while being rendered, and **tags**, which control the template's logic. The template syntax is very similar to [Jinja](http://jinja.pocoo.org/), as well as Jinja-derivatives like [Twig](https://twig.symfony.com/) or [Tera](https://github.com/Keats/tera). 14753
values.rs 8127