web/pages/forms/
message.rs1use askama::Template;
4use axum::response::{IntoResponse, Response};
5
6use crate::response::WebError;
7
8#[derive(Template)]
9#[template(source = "{{ text }}", ext = "html")]
10struct ResultMessage<'a> {
11 text: &'a str,
12}
13
14pub fn escaped(text: &str) -> Result<String, WebError> {
16 ResultMessage { text }
17 .render()
18 .map_err(|e| WebError::internal("Result message render failed", e))
19}
20
21pub fn reply(text: &str) -> Result<Response, WebError> {
23 Ok(escaped(text)?.into_response())
24}
25
26#[cfg(test)]
27#[path = "message_tests.rs"]
28mod tests;