Dynamic Field Functions
Text Helpers
Number Helpers
Logic Helpers
Date Helpers
Text Helpers
lowercase
Turns a string to lowercase.
Parameters: none.
Usage:
//field_100 = "THIS IS A TEST STRING"
β
{{lowercase field_100}}
β
this is a test string
Β
uppercase
Turns a string to uppercase. Opposite ofΒ {{lowercase}}
.
Parameters: none.
Usage:
//field_100 = "this is a test string"
β
{{uppercase field_100}}
β
THIS IS A TEST STRING
Β
capitalizeFirst
Capitalizes the first word in a string.
Parameters: none.
Usage:
//field_100 = "this is a test string"
β
{{capitalizeFirst field_100}}
β
This is a test string
Β
capitalizeEach
Capitalizes each word in a string.
Parameters: none.
Usage:
//field_100 = "this is a test string"
β
{{capitalizeEach field_100}}
β
This Is A Test String
Β
titleize
Capitalizes all words within a string.Β
Parameters: none.
Usage:
//field_100 = "this_is_a_test_string"
β
{{titleize field_100}}
β
This Is a Test String
Β
sentence
Capitalizes the first word of each sentence in a string and converts the rest of the sentence to lowercase.
Parameters: none.
Usage:
//field_100 = "this is string 1. this is string two."
β
{{sentence field_100}}
β
This is string 1. This is string two.
Β
reverse
Reverses a string.
Parameters: none.
Usage:
//field_100 = "this is a test string"
β
{{reverse field_100}}
β
gnirts tset a si siht
Β
truncate
Truncates a string given a specifiedΒ length
, providing a custom string to denote anΒ omission
.
Parameters:
length [int] - The number of characters to keep (Required)
omission [string] - A string to denote an omission (Optional)
Usage:
//field_100 = "This is a longer test string that will be truncated."
β
{{truncate field_100 10 "..."}}
β
This is a lo...
Β
center
Centers a string using non-breaking spaces.
Parameters:
spaces [int] - The number of spaces. (Required)
Usage:
Please note the triple curly braces since this will output HTML.Β
//field_100 = "this is a test string"
β
{{{center field_100 10}}}
β
this is a test string
Β
newLineToBr
Converts new line charactersΒ \n
Β to line breaksΒ <br>
.
Usage:
//field_100 = "this is a \n test string."
β
{{{newLineToBr field_100}}}
β
this is a <br> test string.
Β
sanitize
Sanitizes strings for safe use in URLs and file names.
Parameters:
replacement [string] - A replacement character (Optional)
Usage:
//field_100 = "this is a test string & so is this."
β
{{{sanitize field_100 "-"}}}
β
this-is-a-test-string--so-is-this-
Β
inflect
Returns the plural or singular form of a word based on a count.
Parameters:
singular [string] - The singular form of the word. (Required)
plural [string] - The plural form of the word. (Required)
include [boolean] - whether or not to include the count before the word. (Optional)
Usage:
field_100 = 0
field_101 = 1
β
{{inflect field_100 "lead" "leads"}}
{{inflect field_101 "customer" "customers" true}}
β
lead
1 customer
Β
ordinalize
Turns a number into an ordinal string.Β
Usage:
//field_100 = 3
//field_101 = 1
//field_102 = 22
β
{{ordinalize field_100}}
{{ordinalize field_101}}
{{ordinalize field_102}}
β
3rd
1st
22nd
Number Helpers
toFixed
Returns exactlyΒ digits
Β after the decimal place. The number is rounded if necessary, and the fractional part is padded with zeros if necessary so that it has the specified length.
Parameters:
digits [int] - The number of digits to appear after the decimal point. (Optional)
Usage:
//field_100 = 5.53231
β
{{toFixed field_100 3}}
β
5.532
Β
toPrecision
Returns the number in fixed-point or exponential notation rounded toΒ precision
Β significant digits.
Parameters:
precision [int] - The number of digits. If omitted, it returns the entire number (without any formatting). (Optional)
Usage:
//field_100 = 555.322
β
{{toPrecision field_100 4}}
β
555.3
Β
toExponential
Returns the number in exponential notation with one digit before the decimal point, rounded toΒ fractions
Β digits after the decimal point.
Parameters:
fractions [int] - An integer specifying the number of digits after the decimal point. (Optional)
Usage:
//field_100 = 5
β
{{toExponential field_100 5}}
β
5.00000e+0
Β
toInt
Returns an integer.
Parameters: none.
Usage:
//field_100 = '22.2abc'
β
{{toInt field_100}}
β
22
Β
toFloat
Returns a floating point number.
Parameters: none.
Usage:
//field_100 = '22.2abc'
β
{{toFloat field_100}}
β
22.2
Β
digitGrouping
Adds thousands separator to a number.
Parameters:
separator [string] - A string to use as a digit group separator. (Optional)
Usage:
//field_100 = 2222222
β
{{digitGrouping field_100}}
β
2,222,222
Β
add
Returns the sum of two numbers.
Parameters:
value [int] - The number to add to the expression. (Required)
Usage:
//field_100 = 100
β
{{add field_100 5}}
β
105
Β
subtract
Returns the difference of two numbers. Opposite ofΒ add
Parameters:
value [int] - The number to subtract from the expression. (Required)
Usage:
//field_100 = 100
β
{{subtract field_100 5}}
β
95
Β
divide
Returns the division of two numbers.
Parameters:
value [int] - The number to divide the expression. (Required)
Usage:
//field_100 = 100
β
{{divide field_100 10}}
β
10
Β
multiply
Returns the multiplication of two numbers.
Parameters:
value [int] - The number to multiply the expression. (Required)
Usage:
//field_100 = 100
β
{{multiply field_100 10}}
β
1000
Β
floor
Returns the value rounded down to the nearest integer.
Usage:
//field_100 = 100.5
β
{{floor field_100}}
β
100
Β
ceil
Returns the value rounded up to the nearest integer.
Usage:
//field_100= 100.6
β
{{ceil field_100}}
β
101
Β
round
Returns the value rounded to the nearest integer.
Usage:
//field_100 = 100.69
β
{{round field_100}}
β
101
Β
Logic Helpers
if
The If helper will check if a field value exists. If the condition is met, the code between the opening helper tag and closing helper tag will be processed.
{{#if field_37}}
{{multiply field_37 10}}
{{/if}}
You can also add an 'else' statement if the condition is not met.Β
{{#if field_37}}
// Do something
{{else}}
// Otherwise, do something else
{{/if}}
unless
The Unless helper will check if a field value is blank. If the condition is met, the code between the opening helper tag and closing helper tag will be processed.
{{#unless field_37}}
//Unless field_37 is set, the code here will run.
{{/unless}}
You can also add an 'else' statement if the condition is not met.Β
{{#unless field_37}}
// Do something
{{else}}
// Otherwise, do something else
{{/unless}}
is
Conditionally render a block if the condition is true.
Parameters:
value [string|int] - the value to test against.
Usage:
//field_100 = 5
β
{{#is field_100 5}}
Field 100 is equal to 5
{{else}}
Field 100 is not equal to 5
{{/is}}
β
-or with strings-//field_100 = "Lead"
β
{{#is field_35 "Lead"}}
This customer is a Lead
{{else}}
Customer is not yet a lead.
{{/is}}
Β
isnt
Conditionally render a block if the condition is false. Opposite ofΒ is
.
Parameters:
value [string|int] - the value to test against.
Usage:
//field_100 = 5
β
{{#isnt field_100 5}}
Field 100 isn't 5!
{{else}}
Field 100 is 5
{{/isnt}}
β
Never mind :(
Β
gt
Conditionally render a block if the value is greater than a given number.
Parameters:
value [string|int] - the value to test against.
Usage:
//field_100 = 5
β
{{#gt field_100 8}}
Field 100 is not greater than 8
{{else}}
Field 100 is greater than 8
{{/gt}}
β
Output: Field 100 is greater than 8
Β
gte
Conditionally render a block if the value is greater or equal than a given number.
Parameters:
value [string|int] - the value to test against.
Usage:
//field_100 = 5
β
{{#gte field_100 5}}
Field 100 is greater than or equal to 5
{{else}}
Field 100 is NOT greater than or equal to 5
{{/gte}}
β
Output: Field 100 is greater than or equal to 5
Β
lt
Conditionally render a block if the value is less than a given number. Opposite ofΒ gt
.
Parameters:
value [string|int] - the value to test against.
Usage:
//field_100 = 5
β
{{#lt field_100 3}}
Field 100 is less than 3
{{else}}
Field 100 is not less than 3
{{/lt}}
β
Output: Field 100 is not less than 3
Β
lte
Conditionally render a block if the value is less or equal than a given number. Opposite ofΒ gte
.
Parameters:
value [string|int] - the value to test against.
Usage:
//field_100 = 5
β
{{#lte field_100 5}}
Field 100 is less than or equal to 5
{{else}}
Field 100 is NOT less than or equal to 5
{{/lte}}
β
Output: Field 100 is less than or equal to 5
Β
or
Conditionally render a block if one of the values is truthy.
Parameters:
values [string|int] - the values to test against.
Usage:
field_100 = true
field_101 = false
β
{{#or field_100 field_101}}
Field 100 OR field 101 is true
{{else}}
Neither Field 100 OR field 101 are true
{{/or}}
β
Outptut: Field 100 OR field 101 is true
Β
and
Conditionally render a block if both values are truthy.
Parameters:
values [string|int] - the values to test against.
Usage:
field_100 = true
field_101 = false
β
{{#and field_100 field_101}}
Field 100 and Field 101 are both true
{{else}}
Field 100 and Field 101 are NOT both true
{{/and}}
β
Output: Field 100 and Field 101 are NOT both true
Date Helpers
Format options:
Date (Year, Month, Day):
%Y - Year with century (can be negative, 4 digits at least)
-0001, 0000, 1995, 2009, 14292, etc.
%C - year / 100 (round down. 20 in 2009)
%y - year % 100 (00..99)
β
%m - Month of the year, zero-padded (01..12)
%_m blank-padded ( 1..12)
%-m no-padded (1..12)
%B - The full month name (``January'')
%^B uppercased (``JANUARY'')
%b - The abbreviated month name (``Jan'')
%^b uppercased (``JAN'')
%h - Equivalent to %b
β
%d - Day of the month, zero-padded (01..31)
%-d no-padded (1..31)
%e - Day of the month, blank-padded ( 1..31)
β
%j - Day of the year (001..366)
β
Time (Hour, Minute, Second, Subsecond):
%H - Hour of the day, 24-hour clock, zero-padded (00..23)
%k - Hour of the day, 24-hour clock, blank-padded ( 0..23)
%I - Hour of the day, 12-hour clock, zero-padded (01..12)
%l - Hour of the day, 12-hour clock, blank-padded ( 1..12)
%P - Meridian indicator, lowercase (``am'' or ``pm'')
%p - Meridian indicator, uppercase (``AM'' or ``PM'')
β
%M - Minute of the hour (00..59)
β
%S - Second of the minute (00..60)
β
%L - Millisecond of the second (000..999)
%N - Fractional seconds digits, default is 9 digits (nanosecond)
%3N millisecond (3 digits)
%6N microsecond (6 digits)
%9N nanosecond (9 digits)
%12N picosecond (12 digits)
β
Time zone:
%z - Time zone as hour and minute offset from UTC (e.g. +0900)
%:z - hour and minute offset from UTC with a colon (e.g. +09:00)
%::z - hour, minute and second offset from UTC (e.g. +09:00:00)
%Z - Time zone abbreviation name
β
Weekday:
%A - The full weekday name (``Sunday'')
%^A uppercased (``SUNDAY'')
%a - The abbreviated name (``Sun'')
%^a uppercased (``SUN'')
%u - Day of the week (Monday is 1, 1..7)
%w - Day of the week (Sunday is 0, 0..6)
β
ISO 8601 week-based year and week number:
The week 1 of YYYY starts with a Monday and includes YYYY-01-04.
The days in the year before the first week are in the last week of
the previous year.
%G - The week-based year
%g - The last 2 digits of the week-based year (00..99)
%V - Week number of the week-based year (01..53)
β
Week number:
The week 1 of YYYY starts with a Sunday or Monday (according to %U
or %W). The days in the year before the first week are in week 0.
%U - Week number of the year. The week starts with Sunday. (00..53)
%W - Week number of the year. The week starts with Monday. (00..53)
β
Seconds since the Epoch:
%s - Number of seconds since 1970-01-01 00:00:00 UTC.
β
Literal string:
%n - Newline character (\n)
%t - Tab character (\t)
%% - Literal ``%'' character
β
Combination:
%c - date and time (%a %b %e %T %Y)
%D - Date (%m/%d/%y)
%F - The ISO 8601 date format (%Y-%m-%d)
%v - VMS date (%e-%^b-%4Y)
%x - Same as %D
%X - Same as %T
%r - 12-hour time (%I:%M:%S %p)
%R - 24-hour time (%H:%M)
%T - 24-hour time (%H:%M:%S)
Interval Options:
Example:
{{dateAdd field_91 '1 day' '%Y-%m-%d %I:%M %p'}}
β
The following intervals can be used:
- minute
- hour
- day
- week
- month
- year
Β
formatDate
Formats a date into a string given a format. Accepts any value that can be passed toΒ new Date()
.Β
Parameters:
format [string] - The format string
Usage:
//field_100 = 2021-05-01
β
{{formatDate field_34 "%m/%d/%Y"}}
<br>
{{formatDate field_34 "%I:%M%p"}}
<br>
{{formatDate field_34 "%F"}}
<br>
{{formatDate field_34 "%Y%m%dT%H%M%S%z"}}
β
2021-05-20
05/19/2021
05:00PM
2021-05-19
20210519T170000-0007
Β
now
Returns the current date.
Parameters:
format [string] - The format string
Usage:
{{now}}
{{now "%m/%d/%Y"}}
β
Thu Jul 26 2012 23:41:02 GMT-0400 (AST)
07/26/2012
Β
timeago
Returns a human-readable time phrase from the given date.
Usage:
//field_100 = 2021-05-01
β
{{timeago field_100}}
β
4 days ago
age
Calculates the age in years between a date and now.
Parameters:
β
Usage:
β
dateAdd
Adds a specified interval to a date value.
Parameters:
interval [int|string] - The interval to be subtracted
format [string] - The format string
Usage:
{{dateAdd field_101 '1 day' '%Y-%m-%d'}}
dateSub
Subtracts a specified interval from a date value.
Parameters:
interval [int|string] - The interval to be subtracted
format [string] - The format string
Usage:
{{dateSub field_101 '1 day' %'Y-%m-%d'}}
dateDiff
Calculates the difference between two dates.
Parameters:
format [string] - The format string
Usage:
{{dateDiff field_101 field_102 '%a'}}