Lines
87.5 %
Functions
50 %
Branches
100 %
//! The one escaping path of the plain-text replies swapped into a result box.
use askama::Template;
use axum::response::{IntoResponse, Response};
use crate::response::WebError;
#[derive(Template)]
#[template(source = "{{ text }}", ext = "html")]
struct ResultMessage<'a> {
text: &'a str,
}
/// `text` as HTML-safe markup for an htmx swap into a result box.
pub fn escaped(text: &str) -> Result<String, WebError> {
ResultMessage { text }
.render()
.map_err(|e| WebError::internal("Result message render failed", e))
/// The response of a plain-text `text` reply.
pub fn reply(text: &str) -> Result<Response, WebError> {
Ok(escaped(text)?.into_response())
#[cfg(test)]
#[path = "message_tests.rs"]
mod tests;