//! Rendering a template against an environment chain. //! //! The variables come from the chain, the functions come from the host's //! template callback. Neither of these knows which host it is running under — //! that is the whole point of taking the callback as a parameter. use serde_json::Value; use yaak_models::models::Environment; use yaak_models::render::make_vars_hashmap; use yaak_templates::{RenderOptions, TemplateCallback, parse_and_render, render_json_value_raw}; pub async fn render_template( template: &str, environment_chain: Vec, cb: &T, opt: &RenderOptions, ) -> yaak_templates::error::Result { let vars = &make_vars_hashmap(environment_chain); parse_and_render(template, vars, cb, opt).await } pub async fn render_json_value( value: Value, environment_chain: Vec, cb: &T, opt: &RenderOptions, ) -> yaak_templates::error::Result { let vars = &make_vars_hashmap(environment_chain); render_json_value_raw(value, vars, cb, opt).await }