New Velocity methods

Back to What's New

May 02, 2022

New Property Tool methods

We've added several new class type utility methods to check whether an Object is a given type:

  • isString
  • isList
  • isMap
  • isArray
  • isSet
  • isIterable

Example:

$_PropertyTool.isIterable($category.selectedFieldItems)
## Expected output: true

New List Tool method

A new List Tool method allows you to randomize the order of a List. Example:

$_ListTool.shuffle(["A","B","C"])
## Example output: [B, A, C]

New Number Tool method

A new Number Tool method allows you to test if an Object is a number. Example:

$_NumberTool.isNumeric("3")
## Expected output: true

New Serializer Tool method

A new Serializer Tool method allows you to convert a Map to a JSON String. Example:

#set ($a = {"test": "testing", "array": [1, 2, 3]})
$_SerializerTool.toJson($a)
## Expected output:
{"test":"testing","array":[1,2,3]}

For more information about tools and methods available in Velocity, see our Velocity Tools page.

Categories

Development