let · Step variables
Declare variables for the current step and its descendants, which can be used in templating expressions to create dynamic values.
- _: Say hi
log: ${greeting}
let:
greeting: Bonjour, mes amis !CAUTION
The esquie and __ identifiers are reserved and cannot be used as a variable name. An error will be thrown at runtime when attempting to redefine them.
Variables inheritance
Esquie variables behave similarly to JavaScript scopes, where steps inherit values from their ancestors, unless shadowed.
let:
b: foo
c: bar
# d: # ReferenceError
tasks:
- _: Explaining variables inheritance
let:
a: foo # defined
b: qux # overridden
# c: bar # inherited
- _: --------------------------------
let:
# a: # ReferenceError
# b: foo # inherited
# c: bar # inherited
d: boo # definedAbout templating order
Since records are templatized depth-first and in declaration order (as explained in the templating rules), variables defined earlier may be reused in later variables (even if they are defined in the same let block).
let:
a: foo
tasks:
- _: Showcasing templating order
let:
a: ${a}bar # "foobar"
b:
a: ${a}${b} # "foobar"
b: ${b.a} # "foobar"CAUTION
for and let properties (in this order) are exceptions to the general templating order rule, as they are templatized before any other property in the same step.
- log: ${greeting} # "Bonjour, mes amis !"
let:
greeting: Bonjour, mes amis !WARNING
While the let property can itself be templatized, the resulting value will not be further templatized (as explained in the templating rules.)
- log: ${foo.bar} # "${true}"
let:
foo: "${ { bar: '${true}' } } "