#askama #axum #template #replace #response #deprecated #applications

macro askama-derive-axum

Derive macro for Askama templates with Axum integration. Replacement for future deprecation of askama_axum crate.

3 releases

0.1.2 Feb 21, 2025
0.1.1 Feb 20, 2025
0.1.0 Feb 20, 2025

#475 in Procedural macros

Download history 293/week @ 2025-02-15 126/week @ 2025-02-22 75/week @ 2025-03-01 102/week @ 2025-03-08 159/week @ 2025-03-15

617 downloads per month

MIT/Apache

13KB

Askama-derive-axum

crate-badge docs-badge repo-badge license-badge

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(),
    }
}

License

Copyright (c) Josh McKinney

This project is 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.

See CONTRIBUTING.md.

Dependencies

~3–4MB
~81K SLoC