working on context ergonomics

This commit is contained in:
kitsunecafe 2024-01-24 14:36:59 -05:00
parent 4116cb9728
commit fb413aa8ce
3 changed files with 19 additions and 0 deletions

1
Cargo.lock generated
View file

@ -810,6 +810,7 @@ dependencies = [
"clap",
"glob",
"roxy_core",
"serde",
"syntect",
"tera",
"toml",

View file

@ -10,4 +10,5 @@ roxy_core = { git = "https://github.com/kitsunecafe/roxy-core.git" }
clap = { version = "4.4.17", features = ["derive"] }
toml = "0.8.8"
tera = "1.19.1"
serde = "1.0.195"

View file

@ -108,6 +108,23 @@ impl<'a, P: AsRef<Path> + 'a> FilePath<'a, P> {
}
}
struct Context {
pub inner: tera::Context,
}
impl Context {
pub fn new() -> Self {
Self {
inner: tera::Context::new(),
}
}
pub fn insert<P: AsRef<Path>, K: Serialize, V: Serialize>(&mut self, path: &P, key: K, value: V) {
let path = path.as_ref();
self.inner.insert(&key, &value);
}
}
fn main() -> Result<(), RoxyError> {
let opts = Options::parse();