diff --git a/src/context.rs b/src/context.rs index ada2eed..322267d 100644 --- a/src/context.rs +++ b/src/context.rs @@ -64,7 +64,8 @@ impl Context { let path = file_path.strip_root(path).map_err(anyhow::Error::from)?; - context.insert(&path, &tera::to_value(toml).map_err(anyhow::Error::from)?); + let value = tera::to_value(&toml).map_err(anyhow::Error::from)?; + context.insert(&path, &value); } Ok(context) @@ -127,8 +128,11 @@ impl Context { pub fn insert>(&mut self, path: &P, value: &Value) { let path = Self::as_key(path).map(|p| p.with_extension("")); - if let Some(v) = Self::create_path(&path.unwrap(), value) { - if let Ok(ctx) = tera::Context::from_value(v) { + let path = Self::create_path(&path.unwrap(), value).or(Some(value.clone())); + + if let Some(v) = path { + let value = tera::Context::from_value(v); + if let Ok(ctx) = value { self.merge(ctx); } }