mod gopher;
mod raw;
-use crate::template::{TemplateContext, TemplateValue};
+use crate::template::{Context, Value};
use std::collections::HashMap;
use std::fs::read_dir;
use std::io::Result;
slug: String,
}
-type Archiver = fn(&Path, &Path, &Path, &TemplateContext) -> Result<()>;
+type Archiver = fn(&Path, &Path, &Path, &Context) -> Result<()>;
impl ArchiveEntry {
- pub fn to_template_context(archive_entries: &[ArchiveEntry]) -> TemplateContext {
+ pub fn to_template_context(archive_entries: &[ArchiveEntry]) -> Context {
let mut context = HashMap::new();
let archive_entries_collection = archive_entries
context.insert(
"archive_length".to_string(),
- TemplateValue::Unsigned(archive_entries.len().try_into().unwrap()),
+ Value::Unsigned(archive_entries.len().try_into().unwrap()),
);
context.insert(
"posts".to_string(),
- TemplateValue::Collection(archive_entries_collection),
+ Value::Collection(archive_entries_collection),
);
context
}
- pub fn to_template_value(&self) -> TemplateContext {
+ pub fn to_template_value(&self) -> Context {
let mut context = HashMap::new();
- context.insert("id".to_string(), TemplateValue::String(self.id.clone()));
+ context.insert("id".to_string(), Value::String(self.id.clone()));
- context.insert("slug".to_string(), TemplateValue::String(self.slug.clone()));
+ context.insert("slug".to_string(), Value::String(self.slug.clone()));
if let Some(title) = self.title() {
- context.insert("title".to_string(), TemplateValue::String(title));
+ context.insert("title".to_string(), Value::String(title));
}
context