askama_web

Crates.ioaskama_web
lib.rsaskama_web
version0.14.6
created_at2025-02-21 21:33:47.916915+00
updated_at2025-08-06 16:25:02.933335+00
descriptionA compatibility add-on for Askama to support many different web frameworks
homepagehttps://askama.readthedocs.io/
repositoryhttps://github.com/askama-rs/askama_web/
max_upload_size
id1564751
size179,479
maintainer (github:askama-rs:maintainer)

documentation

README

askama_web

GitHub Workflow Status Crates.io docs.rs

A compatibility add-on for askama to support many different web frameworks.

Example

E.g. if you are using axum, then add askama_web with the feature "axum-0.8" to your Cargo.toml:

[dependencies]
askama_web = { version = "0.14.0", features = ["axum-0.8"] }

Then just add #[derive(WebTemplate)] to your Askama templated struct or enum:

use askama::Template;
use askama_web::WebTemplate;
use axum::Router;
use axum::routing::get;

#[derive(Template, WebTemplate)]
#[template(path = "hello.html")]
struct HelloTemplate {
    name: String,
}

async fn hello() -> HelloTemplate {
    HelloTemplate {
        name: "world".to_string(),
    }
}

let app = Router::new().route("/", get(hello));

By selecting the feature "axum-0.8", HelloTemplate will implement axum::response::IntoResponse. The user will receive a "Status: 200", "Content-Type: text/html; charset=utf-8" response with the rendered struct as body.

Feature flags / web framework selection

These web frameworks are currently implemented and can be selected with their respective feature flag:

As well as these logging / debugging facilities to print error messages if a template could not be rendered:

  • "eprintln": using rust's built-in eprintln!() macro
  • "log-0.4": using log as logging framework
  • "tracing-0.1": using tracing as logging framework

Some older versions are implemented, too:

  • "axum-0.7" / "axum-core-0.4": implements IntoResponse for axum in version 0.7 / axum-core in version 0.4
  • "salvo-0.76""salvo-0.80" / "salvo_core-0.76""salvo-0.80": older Salvo versions
  • "warp-0.3": implements Reply for warp in version 0.3

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 0

cargo fmt