The Let transform wraps another transform, creating a new scope that extends the existing scope.

SpEL expressions inside the let will be able to access variables from both the existing scope (provided that existing variables are not shadowed by variabled defined by the let) as well as variables from the new scope.

Syntax Reference

type: Let
symbols:
- name: <string>
  expression: <SpEL expression>
- ...
in: <transform> # <- new symbols will be visible in here

Execution

The Let adds variables to the new scope by virtue of computation of
SpEL expressions.

engine:
  let:
  - name: <string>
    expression: <SpEL expression>
  - ...

Each symbol MUST be defined by a name and an expression (both required) where * name must be a camelCase string name.

If a let symbol happens to have the same name as a symbol already defined in the surrounding scope, then the local symbol will 'shadow' the one from the surrounding scope. (This makes the variable from the surrounding scope inaccessible in the remainder of the Let but doesn't alter its original value. * expression must be a valid SpEL expression expressed as a YAML string. Care should be taken when using the # symbol for variable evaluation, as this is the comment marker in YAML. Thus, SpEL expressions in YAML should be properly enclosing strings in quotes or rely on block style.

Symbols defined in the Let are evaluated in the new scope, in the order they are defined. This means that symbols lower down the list can make use of the variables defined higher up the list but not the other way around.

See Also

  • Combo provides a way to declare a Let scope as well as other transforms in a short syntax
check-circle-line exclamation-circle-line close-line
Scroll to top icon