tera/builtins/filters/
mod.rs1use std::collections::HashMap;
2
3use crate::errors::Result;
4use serde_json::value::Value;
5
6pub mod array;
7pub mod common;
8pub mod number;
9pub mod object;
10pub mod string;
11
12pub trait Filter: Sync + Send {
14 fn filter(&self, value: &Value, args: &HashMap<String, Value>) -> Result<Value>;
16
17 fn is_safe(&self) -> bool {
19 false
20 }
21}
22
23impl<F> Filter for F
24where
25 F: Fn(&Value, &HashMap<String, Value>) -> Result<Value> + Sync + Send,
26{
27 fn filter(&self, value: &Value, args: &HashMap<String, Value>) -> Result<Value> {
28 self(value, args)
29 }
30}