gsm_runner/
template_node.rs

1use anyhow::Result;
2use gsm_core::MessageEnvelope;
3use handlebars::Handlebars;
4use serde_json::{Value, json};
5
6pub fn hb_registry() -> Handlebars<'static> {
7    let mut h = Handlebars::new();
8    h.set_strict_mode(true);
9    h
10}
11
12pub fn render_template(
13    tpl: &crate::model::TemplateNode,
14    hbs: &Handlebars<'static>,
15    env: &MessageEnvelope,
16    state: &Value,
17    payload: &Value,
18) -> Result<String> {
19    let ctx = json!({
20      "envelope": env,
21      "state": state,
22      "payload": payload
23    });
24    Ok(hbs.render_template(&tpl.template, &ctx)?)
25}