1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
use handlebars::Handlebars;
use source::{Source, SourceError};
use std::collections::BTreeMap;

pub struct MemorySource(pub BTreeMap<String, String>);

impl Source for MemorySource {
    fn load(&self, reg: &mut Handlebars) -> Result<(), SourceError> {
        for (name, tpl) in self.0.iter() {
            try!(reg.register_template_string(name, tpl.clone()))
        }
        Ok(())
    }
}