use axum::http::StatusCode;
use axum::response::Html;
use tracing::error;
use crate::AppState;
pub mod auth;
pub mod cards;
pub mod snippets;
pub use auth::{
handle_create_invite, handle_login, handle_logout, handle_register, show_invites, show_login,
show_profile, show_register,
};
pub use cards::{editor, export, preview};
pub use snippets::{
create_snippet, delete_snippet, edit_snippet, embed, list_snippets, show_snippet, snippet_png,
snippet_svg, update_snippet,
};
/// Render a named template with the given context, mapping failures to a 500
/// plus a log line. Templates are data rather than code, so a typo in one only
/// surfaces here at render time — hence the logging rather than a bare `?`.
pub(crate) fn render(
state: &AppState,
name: &str,
ctx: minijinja::Value,
) -> Result<Html<String>, StatusCode> {
let template = state.env.get_template(name).map_err(|e| {
error!(template = name, error = %e, "load template failed");
StatusCode::INTERNAL_SERVER_ERROR
})?;
let body = template.render(ctx).map_err(|e| {
error!(template = name, error = %e, "render template failed");
StatusCode::INTERNAL_SERVER_ERROR
})?;
Ok(Html(body))
}
neiam
/bismuth
MOTHER-FUCKING-BISMUTH
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
1.2 KiB · text
History
d76cd01