use serde_json::Value;
use std::borrow::Cow;
use std::sync::LazyLock;
mod collection;
mod datetime;
mod env_file;
mod hash;
mod path;
mod printf;
mod text;
mod version;
pub(super) use datetime::translate_go_time_format;
pub(super) use text::register_ruby_escape;
pub use text::ruby_escape_str;
fn value_to_string(v: &Value) -> Cow<'_, str> {
match v {
Value::String(s) => Cow::Borrowed(s.as_str()),
Value::Number(n) => Cow::Owned(n.to_string()),
Value::Bool(b) => Cow::Owned(b.to_string()),
Value::Null => Cow::Borrowed(""),
other => Cow::Owned(other.to_string()),
}
}
fn register_all(tera: &mut tera::Tera) {
text::register_ruby_escape(tera);
text::register(tera);
env_file::register(tera);
version::register(tera);
hash::register(tera);
datetime::register(tera);
path::register(tera);
collection::register(tera);
printf::register(tera);
}
pub(super) static BASE_TERA: LazyLock<tera::Tera> = LazyLock::new(|| {
let mut tera = tera::Tera::default();
register_all(&mut tera);
tera
});
#[cfg(test)]
pub(crate) fn registered_builtin_names() -> std::collections::BTreeSet<&'static str> {
super::engine_adapter::record_registrations(|| {
let mut scratch = tera::Tera::default();
register_all(&mut scratch);
})
}