Skip to main content

Module template

Module template 

Source
Expand description

Template rendering — {{ workload.var }} / {{ step.result }} / {{ result.path }} substitution with a minimal filter set.

Extracted from repos/cli/src/playbook_runner.rs lines 1448-2006 in R-1.1 PR-2b per § H.10.3 of Appendix H of the global hybrid cloud blueprint. The CLI’s tree walker (playbook_runner.rs) and the worker’s NATS-mode runner both render templates the same way; this module is the shared implementation they call into.

Functions take &HashMap<String, String> slices of the per-execution variables and step results so each binary owns its own context shape but feeds the same data into rendering.

Functions§

get_json_path
Get a value from JSON using a path like "status", "body.name", or "items[0].id".
json_to_rhai
Convert a serde_json::Value into a rhai::Dynamic for scripting.
render_template
Render a template by substituting {{ var }}, {{ var | filter }}, {{ workload.var }}, {{ vars.var }}, and {{ step.result }} references against the supplied variable + step-result maps.
render_template_with_result
Render a template that may reference {{ result.path }} against the supplied JSON result value (e.g. the previous step’s HTTP response body), then apply the regular render_template pass for the rest of the references.
rhai_to_json_string
Stringify a rhai::Dynamic value into a JSON-shaped string for embedding into rendered output.