Other assorted useful helpers
assign
helper, then use it
later in your template e.g.:
val
helper can be used to access values or provide a default if the value is not present. It can also be used to
assign a value to a variable much like the assign
helper. The main difference between val
and assign
is that val
will maintain the type of the date being assigned whereas assign
will always assign a string.
size
helper returns the size of a string, list or map:
with
helper creates a nested scope, allowing you to reference attributes on
an object without fully qualifying it each time.
For instance, given a variable whose value is an object with the properties id
and position
,
with
allows these to be accessed without qualifying each time:
range
helper emits an array of integers between the bounds specified in the
first and second parameters (both of which are mandatory).
randomInt
and each
to output random length, repeating pieces of content e.g.
array
helper emits an array containing exactly the values specified as parameters.
arrayAdd
and arrayRemove
helpers can be used to add or remove elements from an array based on a position value
or the start
or end
keywords. If no position is specified, the element will be added or removed from the end of the
array.
arrayJoin
helper will concatenate the values passed to it with the separator specified:
prefix
and suffix
to be added to the start and end of the result:
arrayJoin
helper can also be used as a block helper: