from_yaml

Parses a YAML document into a map, so a config file or a manifest becomes data that later template steps can index into.

It ships as a stub that returns an error until you inject a codec. Parsing YAML needs a real codec, and the core stays free of third-party dependencies rather than forcing one on every consumer, the same way the yaml serializer does. Injecting one is a map entry.

func parseYAML(doc string) (map[string]any, error) {
	var out map[string]any
	err := yaml.Unmarshal([]byte(doc), &out)
	return out, err
}

mods := parse.Modifiers()
mods[string(parse.ModifierNameFromYAML)] = functions.Wrap(parseYAML)
out, err := sintax.New(mods).Render(tpl, vars)
InputArgumentsReturnsstringno argumentsmap[string]any
Source
BasicSource

Parses a YAML document into a map once a codec is injected, so a config file becomes data that later template steps can index into.

Given

{"body": "host: localhost\nregion: eu-west-1"}

Template

{{ body | from_yaml }}

Result

{
  "host": "localhost",
  "region": "eu-west-1"
}
Not injectedSource

Shows what the modifier does before a codec is bound. The stub errors rather than silently parsing nothing, so a missing injection surfaces at render time.

Given

{"body": "host: localhost"}

Template

{{ body | from_yaml }}

Result

error: failed to render template: failed to render variable token 'body': modifier "from_yaml": function failed to apply: from_yaml function needs to be injected