Skip to content

Templates

Templates allow formatting data attributes into strings. The are supported in a number of locations including Dispatch display.

Syntax is a normal string with data attributes escaped by { .. }. The attributes can be formatted with functions. Conditionals are also supported.

Functions

{value | function : parameters}
Function name Name Example Result
capitalize Capitalize {user.name|capitalize} Harry
upper Upper case {user.name|upper} HARRY
date Date format {user.createdAt|date:MMM YYYY} Aug 2020
age Age in years {profile.dob|age} 25
time Format as time from seconds {120|time} 0:02:00
numeral Expressions {values.x+values.y|numeral} 10
numeral Expressions {values.x+values.y|numeral:0.00} 10.00
percent As a percent {values.score|percent} 90%
timeRange Time range {13-14|timeRange} 1:00-2:00pm
suffix Add suffix; use _ for {values.score|suffix:_years} 23 years
prefix Add prefix; use _ for space {values.score|prefix:i=_} i= 23
convert Convert value to metric to imperial {values.height | convert : length} {values.height | convert : length:0.0} 190 cm

Conditionals

It will display the left or right depending on the test.

{test ? value1 : value2}
{test ? value1 : value2 | function : parameters}

Conditional tests

Supported operators: - is | == - not | != - > | < | >= | <= - exits | empty - in (for use with arrays) - includes | excludes (for use with arrays)

Conditional strings

The first with a non empty value will be displayed.

{value1, value2, value3}
{values.value1, values.value2, values.value3}

Switch statement

Switch statements allow matching a dynamic value and showing different output for different values.

{switch(values.test) => 1|dog, 2|cat, 3|turtle, help|bear, *|pear}     

Simple expressions

Simple math expressions can be parsed and formatted; note that operator precenence is not garaunteed.

{ (number *|+|-|/|%|^ number)* | format}

Complex expressions

Complex expressions can be parsed and computed; see Expressions

{{ any supported math expression | format }}

Objects

  • user
  • values (dispatch data)
  • store (for user attributes if loaded)
  • props | data (data access other than dispatch)
  • dispatch (for dispatch attributes)
  • dispatch.attachmentCount
  • dispatch.hasAttachment

Arrays

["dog", "cat", "rabbit", "bear"]

Size

Counts the number of items in an array

{ size( values.metric ) }

Examples

Example Result
{third, second} data 2
{user.createdAt | date:MMM YYYY} Jan 1980
{third, second |capitalize} Data 2
{ 1 is 1 ? first : second |capitalize} Data 1
{ value1 is 10 ? first : second |capitalize} Data 1
{ value2 is 'abc' ? first : second |capitalize} Data 1
{ value1 > 10 ? first : second |capitalize} Data 2
{ value3 | numeral: 0% } 50%
{ value3 | numeral: 0.00} 0.50
{data.values.second} data 2

Dispatch formatting

When applied to a dispatch the values are available directly by referencing with {values.metric}. Additional dispatch information is available through the @ context symbol. Size can be applied to array values as in {size(values.choices) > 0 ? 'has data' : 'no data'} where choices is an array of selections.

Attributes avaialble

  • attachmentCount
  • hasAttachment
  • userName
  • authorName
  • swimlaneName
  • trackerName
  • orgName