1 use crate::config::Config;
3 use std::collections::HashMap;
11 pub variables: HashMap<String, Value>,
15 /// Create a new cache, used to read files only once and otherwise store their contents.
16 pub fn new(config: &Config) -> Cache {
17 let root = Path::new(&config.doc_dir);
18 let filename = Path::new(&config.template).file_stem().unwrap();
19 let file_path = root.join(&Path::with_extension(Path::new(filename), "json"));
20 let content = fs::read_to_string(&file_path).expect("failed to read JSON file");
23 value: serde_json::from_str::<Value>(&content).expect("failed to convert from JSON"),
24 variables: HashMap::new(),
28 pub fn value(&self) -> &Value {