Skip to main content

fold

fold is a DTL operation that collapses a single-child mapping by promoting its only child.

Use it to remove unnecessary wrapper nodes.

YOp

- fold:
path: config/wrapper

Parameters

ParameterTypeRequiredDescription
pathstringyesPath to the wrapper mapping. It must have exactly one child key.

Behavior

  • Requires the path to exist.
  • Requires the target to be a mapping with exactly one key.
  • Removes the wrapper key.
  • Promotes the single child to the wrapper's former position.

Errors

ErrorMeaning
PATH_NOT_FOUNDTarget path does not exist.
NOT_FOLDABLEThe mapping has zero keys or more than one key.

Example

yops:
- fold:
path: config/wrapper

Input:

config:
wrapper:
actual:
data: 1

Output:

config:
actual:
data: 1