Working with if statements, loops and collections.
unless
:
if
, else if
and unless
helpers all take a single boolean value
as their parameter. In practice you often need to derive that value by comparing
other values, and for this we have a set of helpers implementing common comparison operations.
For instance if you needed to check that a variable equalled a particular string
you would use the eq
helper:
if
helper:
else
:
eq
- equal
neq
- not equal
gt
- greater than
gte
- greater than or equal to
lt
- less than
lte
- less than or equal
and
- logical AND
or
- logical OR
not
- logical NOT
each
helper.
jsonPath
and xPath
helpers both output collections so these can be used
in an each
loop. See Working with JSON and
Working with XML for details.
@first
and @last
variables that are automatically
provided to the scope inside the each
block.
For instance, if you wanted to output a list of JSON objects, separated with
commas and avoiding an extraneous comma at the end:
each
helper also creates an @index
variable in its scope which you can use
to get at the (zero-indexed) element counter:
contains
helper returns a boolean value indicating whether the string or array passed as the first parameter
contains the string passed in the second.
It can be used as parameter to the if
helper:
matches
helper returns a boolean value indicating whether the string passed as the first parameter matches the
regular expression passed in the second:
Like the contains
helper it can be used as parameter to the if
helper: