#askama #template #axum #response #replace #macro #askama-axum

macro askama-derive-axum

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

3 releases

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

#354 in Procedural macros

Download history

78 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

~2.9–4MB
~75K SLoC