1
Fork 0
advent-of-code/source/templates/mod.rs

22 lines
518 B
Rust
Raw Normal View History

2024-01-14 21:04:10 +00:00
//! The templating code for [`askama`].
use askama::Template;
use crate::solution::Solution;
2024-01-14 21:04:10 +00:00
/// The HTML template for all solutions.
#[derive(Template)]
#[template(path = "solutions.html")]
pub struct SolutionsTemplate {
2024-01-14 21:04:10 +00:00
/// All solutions grouped by year.
pub years: Vec<Vec<Solution>>,
}
2024-01-14 21:04:10 +00:00
/// Custom [`askama`] filters.
pub mod filters {
2024-01-14 21:04:10 +00:00
/// See [`crate::utilities::random_emoji`].
pub fn random_emoji(s: &str) -> askama::Result<String> {
Ok(format!("{s} {}", crate::utilities::random_emoji()))
}
}