askama_web
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:
[]
= { = "0.12.0-pre.0", = ["axum-0.8"] }
Then just add #[derive(WebTemplate)] to your Askama templated struct or enum:
use Template;
use WebTemplate;
use Router;
use get;
async
let app = new.route;
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:
-
"actix-web-4": implementResponderfor actix-web in version 4 -
"axum-0.8"/"axum-core-0.5": implementIntoResponsefor axum in version 0.8 / axum-core in version 0.5 -
"poem-3": implements forIntoResponsefor poem in version 3.x -
"rocket-0.5": implementsResponderfor rocket in version 0.5 -
"salvo-0.76"/"salvo_core-0.76": implementScribefor salvo in version 0.76 / salvo_core in version 0.76 -
"salvo-0.77"/"salvo_core-0.77": implementScribefor salvo in version 0.77 / salvo_core in version 0.77
As well as these logging / debugging facilities to print error message if a template could not be rendered:
-
"eprintln": using rust's built-ineprintln!()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": implementIntoResponsefor axum in version 0.7 / axum-core in version 0.4
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
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.