Crate askama_derive_axum

Crate askama_derive_axum 

Source
Expand description

Derive macro for implementing IntoResponse for Askama templates.

This crate provides a derive macro for implementing IntoResponse for Askama templates. This allows you to use Askama templates as responses in Axum applications. It is a replacement for the askama_axum crate, which will be no longer available in askama 0.13. See askama#1128 and askama#1119 for more information.

§Example

use askama::Template;
use askama_derive_axum::IntoResponse;

#[derive(Template, IntoResponse)]
#[template(path = "index.html")]
struct IndexTemplate {
    title: String,
    body: String,
}

async fn index() -> IndexTemplate {
    IndexTemplate {
        title: "My Blog".to_string(),
        body: "Hello, world!".to_string(),
    }
}

Derive Macros§

IntoResponse
Derive macro for implementing IntoResponse for Askama templates.