Skip to main content

parse_format

Function parse_format 

Source
pub fn parse_format(
    format: &str,
    _context: &Context,
    module_outputs: &HashMap<String, String>,
) -> String
Expand description

Parses format string and substitutes variables with module outputs

Replaces $<name> tokens anywhere in the string (not only when separated by whitespace) with their corresponding rendered outputs. Unknown tokens are removed (replaced by an empty string).

§Arguments

  • format - Format string containing $<name> variable tokens
  • _context - Context (reserved for future use)
  • module_outputs - Map of module names to their rendered outputs

§Returns

A string with all $<name> tokens replaced by their values while preserving all other characters (including spaces) verbatim.

§Examples

let mut outputs = HashMap::new();
outputs.insert("directory".to_string(), "~/project".to_string());
outputs.insert("claude_model".to_string(), "Opus".to_string());

let result = parse_format("$directory $claude_model", &context, &outputs);
assert_eq!(result, "~/project Opus");