This commit is contained in:
kitsunecafe 2024-02-22 01:14:29 -05:00
parent 4a70eb6c05
commit d814efcf93

View file

@ -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<P: AsRef<Path>>(&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);
}
}