pagetop/src/core/theme/mod.rs
Manuel Cillero 3764f707da Añade elección de tema específico por página
Característica útil para facilitar que el módulo Admin pueda renderizar
sus páginas siempre con el mismo tema, indepedientemente del tema por
defecto. También podrá ser decisivo para permitir a los usuarios usar un
tema diferente.
2022-02-26 21:15:00 +01:00

18 lines
445 B
Rust

use crate::core::all::THEMES;
pub use maud::{DOCTYPE, Markup, PreEscaped, html};
mod api;
pub use api::Theme;
pub fn register_theme(t: &'static (dyn Theme + 'static)) {
THEMES.write().unwrap().push(t);
}
pub fn find_theme(name: &str) -> Option<&'static (dyn Theme + 'static)> {
let themes = THEMES.write().unwrap();
match themes.iter().find(|t| t.name() == name) {
Some(theme) => Some(*theme),
_ => None,
}
}