YAML filters are used to turn YAML strings into objects.


yaml

This filter, added in kestra 0.16.0, is used to parse a YAML string into an object. That object can then be transformed using Pebble templating engine.

The filter is useful when working with the TemplatedTask added in #3191.

twig
{{ "foo: bar" | yaml }}
Full workflow example using the filter in a templated task

indent

When constructing YAML from multiple objects, this filter can apply indentation to strings, adding amount number of spaces before each line except for the first line.

The prefix property defines what is used to indent the lines. By default, prefix is " " (a space).

The syntax:

twig
indent(amount, prefix=" ")

nindent

Use nindent to add a new line (hence the n in nindent) before the code and then indent all lines by adding amount number of spaces before each line. The amount is a required property defining how many times prefix is repeated before each line.

The prefix property defines what is used to indent the lines. By default, prefix is " " (a space).

The syntax:

twig
nindent(amount, prefix=" ")
Full workflow example using the indent filter
Sample code for testing the indent filter
Sample code for testing the nindent filter