MCPcopy Create free account
hub / github.com/github/gh-aw / substituteImportInputsInContent

Function substituteImportInputsInContent

pkg/parser/import_field_extractor.go:1335–1343  ·  view source on GitHub ↗

substituteImportInputsInContent performs text-level substitution of ${{ github.aw.import-inputs.* }} and ${{ github.aw.inputs.* }} expressions in raw file content (including YAML frontmatter). This is called before YAML parsing so that array/object values serialised as JSON produce valid YAML.

(content string, inputs map[string]any)

Source from the content-addressed store, hash-verified

1333// in raw file content (including YAML frontmatter). This is called before YAML
1334// parsing so that array/object values serialised as JSON produce valid YAML.
1335func substituteImportInputsInContent(content string, inputs map[string]any) string {
1336 if len(inputs) == 0 {
1337 return content
1338 }
1339
1340 result := legacyInputsExprRegex.ReplaceAllStringFunc(content, buildImportInputReplaceFunc(legacyInputsExprRegex, inputs))
1341 result = importInputsExprRegex.ReplaceAllStringFunc(result, buildImportInputReplaceFunc(importInputsExprRegex, inputs))
1342 return result
1343}
1344
1345func buildImportInputReplaceFunc(regex *regexp.Regexp, inputs map[string]any) func(string) string {
1346 return func(match string) string {

Calls 1

Tested by

no test coverage detected