Transformers

Sometimes the data coming from the design data model is not in a format you'd like it to have. For example, you want the uppercased name of the token, but the data model only provides a real name. For this situation, it is also possible to change attributes using transformers. Transformers take an input value, run it through transformation, and retrieve the result. You use them through dot notation:

{{ name.uppercased() }} // Name = "primary"

Producing this expected output when used:

PRIMARY

Transformers can also be chained, like this:

{{ name.uppercased().prefixed("--")}}

Which will transform the value using all transformers from left to right, producing:

--PRIMARY

There are a plethora of transformers available for each supported data type. Note that transformers can only be used on the data type they are listed under. For example, uppercased() can only be used on string values while random() can be used on arrays.

String Transformers

Following string transformers are available:

Array Transformers

Following array transformers are available:

Object Transformers

Following object transformers are available:

Numeric Transformers

Following numeric transformers are available:

Support Transformers

Support transformers are special because can be used on any data type.

Following support transformers are available:

Last updated