use askama::Template;
#[derive(Debug)]
pub struct WindTemplate<T: Template> {
template: T,
}
impl<T: Template> WindTemplate<T> {
pub fn from(template: T) -> Self {
WindTemplate { template }
}
pub fn render(template: T) -> String {
WindTemplate { template }.to_string()
}
pub fn r(&self) -> Vec<u8> {
let template = match self.template.render() {
Ok(template) => format!("20 text/gemini\r\n{}", template),
Err(error) => format!("50 text/gemini\r\n{}", error),
};
template.into_bytes()
}
pub fn to_string(&self) -> String {
match self.template.render() {
Ok(template) => template,
Err(error) => format!("50 text/gemini\r\n{}", error),
}
}
}