boots_core/template/
embedded.rs

1use rust_embed::Embed;
2
3#[derive(Embed)]
4#[folder = "templates/"]
5pub struct Templates;
6
7impl Templates {
8    pub fn get_template(path: &str) -> Option<String> {
9        Self::get(path).map(|f| String::from_utf8_lossy(&f.data).to_string())
10    }
11
12    pub fn list_templates(prefix: &str) -> Vec<String> {
13        Self::iter()
14            .filter(|path| path.starts_with(prefix))
15            .map(|path| path.to_string())
16            .collect()
17    }
18}