Template Functions

There are a number of functions you can use inside the templating language. Functions must appear inside of braces.

{{ upperCaseFirstLetter('jim') }}

The following is a complete list of available functions.

Mathematical Functions

Function Description Example Output
absoluteValue(number) Returns the absolute value of a number. absoluteValue(2)
absoluteValue(-2)
2
2
arcCosine(number) The inverse cosine. Returns radians. arcCosine(-0.5) 2.094395
arcSine(number) The inverse sine. Returns radians. arcSine(-0.5) -0.523598
arcTangent(number) The inverse tangent. Returns radians. arcTangent(-0.5) -0.463647
ceiling(decimal) Returns the largest integer from a decimal number. ceiling(4.2) 5
cosine(number) Returns the cosine of the number. cosine(0) 1
floor(decimal) Returns the smallest integer from a decimal number. floor(4.2) 4
max(number, max) Returns a number equal to or lower than the max. max(5,3)
max(1,3)
3
1
maxOfAll(num1, num2, num3) Returns the largest number from the input list. Accepts any number of arguments. maxOfAll(1,2,3)
maxOfAll(112, 54, 78)
3
112
min(number, min) Returns a number equal to or higher than the min. min(5,3)
min(1,3)
5
3
minOfAll(num1, num2, num3) Returns the smallest number from the input list. Accepts any number of arguments. minOfAll(1,2,3)
minOfAll(112, 54, 78)
1
54
number(string) Converts a string to a number. number('42')
number('3.14')
42
3.14
pi A constant holding the value of PI. pi 3.14159265359
random(min, max) Returns a random integer between two integers (inclusive). random(1,10)
random(1,10)
random(1,10)
3
1
9
range(number, min, max) Returns a number between min and max (inclusive). range(1,3,5)
range(3,1,5)
range(5,1,3)
3
3
3
round(decimal) Returns the smallest integer from a decimal number if the remainder is less than 5 or the highest when it's 5 or above. round(4.2) 4
sine(number) Returns the sine of the number. sine(0) 0
squareRoot(number) Returns the square root of the number. squareRoot(4) 2
tangent(number) Returns the tangent of the number. tangent(30) -6.405331

String Functions

Function Description Example Output
endsWith(str, end) Returns true if the last characters of str match end. endsWith('Fred','ed')
endsWith('Fred','er')
true
false
format(pattern, val1, val2, val3) Returns a formatted string using a replacement pattern. Use %s for a string variable and %d for a digit and %.2f for a number with 2 places after a decimal.

For more detailed information on what you can do with this, check out this external documentation.
format('The %s costs $%.2f.', 'tea', 1.991) The tea costs $1.99.
inText(str, inc) Returns true if inc is found anywhere inside of str. inText('Fred', 'red')
inText('Fred', 'foo')
true
false
join(sep, str1, str2, str3) Concatenates all of the str with the sep. Accepts any number of parameters. join('//', 'green', 'red', 'yellow') green//red//yellow
length(string) Returns the number of characters in a string. length('crafter') 7
lowerCase(string) Lower cases a string. lowerCase('aBcDeF') abcdef
plural(str, num, inclusive) Allows you to create pluralized text in an easy manner based upon what the value of the integer is. plural('test')
plural('test', 0)
plural('test', 1)
plural('test', 5)
plural('test', 1, true)
plural('test', 5, true)
plural('蘋果', 2, true)
tests
tests
test
tests
1 test
5 tests
2 蘋果
repeat(string, number) Repeats some text a certain number of times. Is often used for repeating an icon a certain number of times. repeat('X',4) XXXX
replace(string, find, replace) Replaces all occurrences of one string with another inside a third string. replace('Text','x', 'X')
replace('Text','', ' - ')
replace('Requires 3 water.', 'water', '<water/>')
TeXt
T - e - x - t
Requires 3 <water/>.
reverse(string) Reverses a string. reverse('Hello') olleH
reverseWords(string) Reverses the order of words in a string. reverseWords('Hello World') World Hello
split(string, position, delimiter) Splits a string based upon a delimiter. The delimiter defaults to '-'. By default the first value position (0) will be returned. You can specify another value position optionally. split('red-green-blue')
split('red-green-blue',1)
split('red_green_blue',1,'_')
red
green
green
splitToList(string, delimiter) Splits a delimited string into an array with trimmed whitespace. The delimiter defaults to ','. Useful with loops to process comma-separated values. splitToList('red, green, blue')
splitToList('apple|orange|banana', '|')
['red', 'green', 'blue']
['apple', 'orange', 'banana']
startsWith(str, start) Returns true if str begins with start. startsWith('Food','Foo')
startsWith('Food','Bar')
true
false
substring(str, start, length) Returns a portion of a string. substring('Component', 1, 2)
substring('Component', 0, 4)
om
Comp
upperCase(string) Upper cases a string. upperCase('aBcDeF') ABCDEF
upperCaseFirstLetter(string) Upper cases the first letter in a string. upperCaseFirstLetter('aBcDeF') ABcDeF
upperCaseEachWord(string) Upper cases the first letter in each word in the string. upperCaseEachWord('component studio') Component Studio

Layer Functions

Function Description Example Output
centerMeX() Returns the left corner position needed to center the current layer within the design. Can also take a parameter to center itself inside another layer. centerMeX()
centerMeX('layer name')
75
125
centerMeY() Returns the top corner position needed to center the current layer within the design. Can also take a parameter to center itself inside another layer. centerMeY()
centerMeY('layer name')
75
125
currentLayerName() Returns the name of the current layer being processed. currentLayerName() Battle Icon
layerBottom(name) Returns the Y position of the bottom of the named layer. Also see $previous below. layerBottom('layer name') 200
layerHeight(name) Returns the height of the named layer. Also see $previous below. layerHeight('layer name') 100
layerLeft(name) Returns the X position of the left-side of the named layer. Also see $previous below. layerLeft('layer name') 40
layerRight(name) Returns the X position of the right-side of the named layer. Also see $previous below. layerRight('layer name') 70
layerTop(name) Returns the Y position of the top of the named layer. Also see $previous below. layerTop('layer name') 25
layerVisible(name) Returns true if the named layer is visible, false if hidden. layerVisible('layer name') true
layerWidth(name) Returns the width of the named layer. Also see $previous below. layerWidth('layer name') 300

Table Cell Functions

These functions work specifically with table layer cells. All cell functions support an optional excludePadding parameter.

Function Description Example Output
cellBottom(name, excludePadding) Returns the Y position of the bottom of the named cell. The excludePadding parameter (optional) adjusts for cell padding. cellBottom('A1') 50
cellHeight(name, excludePadding) Returns the height of the named cell. The excludePadding parameter (optional) adjusts for cell padding. cellHeight('A1') 30
cellLeft(name, excludePadding) Returns the X position of the left side of the named cell. The excludePadding parameter (optional) adjusts for cell padding. cellLeft('A1') 10
cellRight(name, excludePadding) Returns the X position of the right side of the named cell. The excludePadding parameter (optional) adjusts for cell padding. cellRight('A1') 60
cellTop(name, excludePadding) Returns the Y position of the top of the named cell. The excludePadding parameter (optional) adjusts for cell padding. cellTop('A1') 20
cellWidth(name, excludePadding) Returns the width of the named cell. The excludePadding parameter (optional) adjusts for cell padding. cellWidth('A1') 50
cellValue(name, field) Returns a specific value from a cell's calculated fields. Useful for accessing cell properties beyond position and size. cellValue('A1', 'text') Hello

Utility Functions

Function Description Example Output
cite() Returns the calculated value of a Dataset cell or a Layer property for the same row or layer. Only useable in the Dataset and Layer fields. Not compatible with fields that utilize the random() function. Click the label name for a Layer property to copy the correct cite() call to the clipboard. cite('column')
cite('width')
5
675
get(variable) Returns a variable set earlier using the set() function. get('foo') bar
inList(test, val1, val2, val3) Returns true if test is equal to any of the values. Accepts any number of parameters. inList('red', 'green', 'blue', 'black')
inList('red', 'green', 'red', 'black')
false
true
renderVersion(detail) Returns a version number that can be rendered onto your components to make for easier tracking of when something was generated. The version number is year down to seconds separated by dots. Detail level determines how many parts of the version to show and ranges from 1 to 6. renderVersion()
renderVersion(1)
renderVersion(2)
renderVersion(3)
renderVersion(4)
renderVersion(5)
renderVersion(6)
2022.3.21
2022
2022.3
2022.3.21
2022.3.21.19
2022.3.21.19.4
2022.3.21.19.4.17
rows() Returns a collection of all enumerated rows in the dataset. When used in a loop you can access cell values of each row. {% for item in rows() %}
  {{item.name}}
{% endfor %}
Card_1
Card_2
Card_3
set(variable, value) Set a variable for retrieval later. set('foo','bar')
setGet(variable, value) Set a variable for retrieval later, but also output it now. setGet('foo','bar') bar

Special Variables

$previous

There is a special layer called $previous that can be used by layerBottom(), layerTop(), layerWidth(), layerHeight(), layerLeft(), and layerRight(). This layer points to the previously rendered layer (not layer group). You'd use it like this:

{{ layerBottom('$previous') }}

This is useful, for example, to stack multiple variable-height text layers together, especially if some of them are conditionally rendered. To make this work the text layers will usually have their "Height Boundary" property set to "used".

Note: Functions highlighted in green are newly documented features that were previously undocumented.

Video Tutorials

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us