Use HTML swap to display success and error messages

This commit is contained in:
Alphonse Paix
2025-09-17 03:40:23 +02:00
parent 88dad022ce
commit 2d336ed000
18 changed files with 134 additions and 232 deletions

View File

@@ -1,19 +1,10 @@
use askama::Template;
use axum::response::Html;
use axum_messages::Messages;
#[derive(Template)]
#[template(path = "../templates/home.html")]
struct HomeTemplate {
message: String,
}
struct HomeTemplate;
pub async fn home(messages: Messages) -> Html<String> {
let template = HomeTemplate {
message: messages
.last()
.map(|msg| msg.to_string())
.unwrap_or_default(),
};
Html(template.render().unwrap())
pub async fn home() -> Html<String> {
Html(HomeTemplate.render().unwrap())
}