roxy-cli/src/functions.rs
2024-02-11 06:45:28 -05:00

17 lines
476 B
Rust

use std::collections::HashMap;
use tera::{to_value, try_get_value, Map, Result, Tera, Value};
pub fn values(value: &Value, _args: &HashMap<String, Value>) -> Result<Value> {
println!("value {value:?}");
let arr = try_get_value!("values", "value", Map<String, Value>, value)
.into_iter()
.map(|(_, x)| x)
.collect();
Ok(to_value::<Value>(arr)?)
}
pub fn register_functions(tera: &mut Tera) {
tera.register_filter("values", values);
}