pub fn substitute_variables<S: BuildHasher>(
content: &str,
values: &HashMap<String, String, S>,
variables: &[PromptVariable],
) -> Result<String>Expand description
Substitutes variables in prompt content.
§Arguments
content- The template content with{{variable}}placeholders.values- A map of variable names to their values.variables- Variable definitions for defaults and required checks.
§Security
All user-provided variable values are sanitized via sanitize_variable_value
to prevent template injection attacks:
- Nested
{{...}}patterns in values are escaped - Control characters are removed
- Excessively long values are truncated
§Errors
Returns an error if a required variable is missing and has no default.