Skip to main content

apply_variables

Function apply_variables 

Source
pub fn apply_variables(
    value: &mut Value,
    overrides: Option<&HashMap<String, Value>>,
    path: &str,
) -> Result<()>
Expand description

Apply variable substitution to a JSON Value. Extracts the “variables” definitions, merges with optional overrides, then substitutes.

When a config block is present, overrides must reference declared variables (unknown names produce UndefinedVariable).

When there is no config block but overrides are provided (e.g. from the CLI for an HTML scenario that cannot carry a config key), the overrides are applied as raw value substitutions without type declarations — any $name found in the document is replaced by the override value as-is. Unresolved references after this pass are ignored (no UnresolvedVariable error), because the document may legitimately contain no variable references at all.