Formatting Your Data
This section guides you to format your data. For example, you want to display your text in uppercase or lowercase and much more. Here formatting doesn't mean styling your content (font, size, color).
Here is a list of available modifiers/helpers. These modifiers/helpers are added along with the tokens(merge field).
Modifier/Helper | Description | Example |
---|---|---|
Uppercase | Convert all characters to uppercase | {{upper FieldName}} |
Lowercase | Convert all characters to lowercase | {{lower FieldName}} |
Capitalize | Capitalize the first letter | {{capitalize FieldName}} {{capitalize FieldName format="words"}} |
Abbreviation | Convert text to abbreviation (First letter of each word in caps) | {{abbreviate FieldName "."}} |
Pad | Appends or prepends a single character repeatedly to fill input to given width. | {{pad number 9}} {{pad number 5 pad_with='*' style='suffix'}} |
Concat | Appends text. | {{concat string1 string2}} |
Format Date | Change the format of date, datetime | {{format_date _date format="DD-MM-YY"}} {{format_date _date format="DD-MMMM-YYYY" locale="fr"}} {{format_date _date format="DD-MMMM-YYYY" locale="en" offset="+3 years"}} |
Format Number | Change the format of a number (thousands and decimals) | {{format_number number decimal_separator="."}} {{format_number number thousand_separator=","}} {{format_number number precision="2"}} {{format_number number thousand_separator="," decimal_separator="." precision="3"}} |
Format Phone | Change the format of your phone number. It can also be used to format a number | {{format_phone landline "(%3) %3-%4"}} |
Number to words | Converts the input number in to words. | {{number_to_words input}} |
Number to Ordinal | Converts the input number to its ordinal form, in words. | {{number_to_ordinal input}} |
Join | Joins the input array of strings with given separator (defaults to | {{join items ", "}} {{join FieldName ", " lookup="object.name"}} |
Replace | Replaces the match string from input with given replace string | {{replace str1 str2}{{replace FieldName (regex "[0-9]" "g") "*"}} |
Regex | Return a RegExp class instance with given pattern and flags | {{replace FieldName (regex "(0-9)" "g") "*"}} |
Split | Splits input with given separator (defaults to | {{#each (split Fieldname ", ")}} ... {{/each}} |
Strip | Strips the input of given match characters (defaults to white space) from given position ( | {{strip FieldName}} {{strip FieldName "*" side="left"}} |
Sort | Sorts input in the given order ( | {{# list (sort FieldName lookup="price" order="asc")}} ... {{/list}} {{#list (sort Fieldname order="asc")}} ... {{/list}} |
Var | Can be used to store and retrieve the data within the template | {{var "FieldName" 500}} {{var "FieldName"}} |
Group by | Groups data by given lookup. | {{#each (group_by FieldName lookup="company")}}..... {{/each}} |
Insert Link | Inserts a URL or Hyperlink in the document | {{insert_link url text="clickable display text"}} |
Url Encode | Replaces special characters inside a URL with encoded text. | {{url_encode URL is_url=true|false}} |
Url Decode | Decodes encoded URLs into pre-encoded forms. | {{url_decode URL is_url=true|false}} |
Rand | Returns a random value between the specified minimum and maximum values. | {{rand min max}} |
As Number | Converts any given input to a valid number. | {{as_number FieldName}} |
As String | Converts any given input to a valid string. | {{as_string FieldName}} |
As Boolean | Converts any given input to True or False. | {{as_boolean FieldName}} |
Format Date/Time
Syntax: {{format_date token_name format="format" locale="language_code" offset="add/subtract time"}}
1 | format | No | MM-DD-YYYY |
---|---|---|---|
2 | language code | No | en English(United States) |
3 | add/subtract time | No |
Example | Input | Output |
---|---|---|
| 2019-05-25 | 25-05-19 |
| 2019-05-25 | mai 25 2019 |
| 2019-08-20 | August 20 2020 |
| 2019-08-20 | 08-20-2020 |
Example formats | Output |
---|---|
DD-MM-YY | 21-11-18 |
Do-MM-YY | 6th-08-21 |
ddd MMM DD HH:mm:ss | Wed Nov 21 14:08:25 |
MMMM DD YYYY HH:mm:ss | November 21 2018 14:08:25 |
MMMM DD YYYY | November 21 2018 |
MMM DD YYYY | Nov 21 2018 |
YYYY-MM-DD | 2018-11-21 |
MM-DD-YYYY | 01-22-2006 |
MM/DD/YYYY | 01/22/2006 |
MM/DD/YY | 01/22/06 |
DD-MM-YYYY | 22-01-2006 |
DD/MM/YYYY | 22/01/2006 |
DD/MM/YY | 22/01/06 |
X | 1542758400 |
Date/Time Format
Token | Output | |
---|---|---|
Year | YYYY | 2000, 2001, 2002 ... 2012, 2013 |
YY | 00, 01, 02 ... 12, 13 | |
Month | MMMM | January, February, March ... |
MMM | Jan, Feb, Mar ... | |
MM | 01, 02, 03 ... 11, 12 | |
M | 1, 2, 3 ... 11, 12 | |
Day of Year | DDDD | 001, 002, 003 ... 364, 365 |
DDD | 1, 2, 3 ... 364, 365 | |
Day of Month | DD | 01, 02, 03 ... 30, 31 |
D | 1, 2, 3 ... 30, 31 | |
Do | 1st, 2nd, 3rd, 4th ...... 30th, 31st | |
Day of Week | dddd | Monday, Tuesday, Wednesday ... |
ddd | Mon, Tue, Wed ... | |
d | 1, 2, 3 ... 6, 7 | |
Hour | HH | 00, 01, 02 ... 23, 24 |
H | 0, 1, 2 ... 23, 24 | |
hh | 01, 02, 03 ... 11, 12 | |
h | 1, 2, 3 ... 11, 12 | |
AM / PM | A | AM, PM |
a | am, pm | |
Minute | mm | 00, 01, 02 ... 58, 59 |
m | 0, 1, 2 ... 58, 59 | |
Second | ss | 00, 01, 02 ... 58, 59 |
s | 0, 1, 2 ... 58, 59 | |
Sub-second | SSS | 000, 001, 002 ... 998, 999 |
SS | 00, 01, 02 ... 98, 99 | |
S | 0, 1, 2 ... 8, 9 | |
Timestamp | X | 1381685817 |
Language
Language code | Language & Country |
---|---|
en-au | English (Australia) |
en-ca | English (Canada) |
en-ie | English (Ireland) |
en-il | English (Israel) |
en-nz | English (New Zealand) |
en-gb | English (United Kingdom) |
fr | French |
fr-ca | French (Canada) |
fr-ch | French (Switzerland) |
de | German |
de-at | German (Austria) |
de-ch | German (Switzerland) |
hu | Hungarian |
pt | Portuguese |
Add/Subtract Time - Manipulate a date and/or time by adding/subtracting time.
To adjust a date/time by a specific amount, you need to supply <+/-> <amount as a number> <unit>
as the value for offset. Unit can be "years", "months", "weeks", "days", "hours", "minutes", or "seconds". Here are some examples:
+1hours
-3days
+5years+2months-3minutes
+8h
Example | Input | Output |
---|---|---|
| 2019-08-20 | August 20 2020 |
| 2019-08-20 | February 20, 2020 |
| 2019-08-20 | 08-20-2020 |
Format Number
Syntax: {{format_number number output_format="in" thousand_separator="thousand_sep" decimal_separator="decimal_sep" precision="number_of_decimal_places"}}
Example | Input | Output |
---|---|---|
| 123456 | 123.456 |
| 12345.12345 | 12.345,123 |
| 123456 | 123,456.00 |
| 909.876 | 909,876 |
| 87904.987 | 87,904.987 |
| 87904.987 | 87,904.99 |
Abbreviation
Syntax: {{abbreviate FieldName separator}}
The Separator is not mandatory.
Example | Input(name) | Output |
---|---|---|
| John Doe | JD |
| John Doe | J.D |
Format Phone
Syntax: {{format_phone landline "format"}}
Example | Input | Output |
---|---|---|
| 9878072739 | (987) 807-2739 |
| 9876543210 | +1-987-654-3210 |
| 1234567890123456 | 1234-5678-9012-3456 |
Number to words
Format: {{number_to_words input output_format="in" suffix=" " decimal_suffix=" " language=" "}}
Example | Input | Output |
---|---|---|
| 123456 | one hundred and twenty-three thousand four hundred and fifty-six |
| 800.658 | Eight hundred dollars six hundred and fifty-eight cents |
| 9893.567 | nine thousand eight hundred and ninety-three rupees five hundred and sixty-seven paise |
| 7000000 | seventy lakh rupees |
| 7000000 | seven million dollars |
| 8795 | huit mille sept cent quatre-vingt-quinze |
| 8790.345 | achttausendsiebenhundertneunzig Dollars dreihundertfünfundvierzig Cents |
Number to Ordinal
Format: {{number_to_ordinal Number}}
Example
Input | Output | |
---|---|---|
| 800 | eight hundreth |
| 582 | Five hundred and eighty-second |
| 789.325 | seven hundred and eighty-ninth |
Join
Syntax: {{join content separator lookup="lookup_key"}}
Example 1:
{{join SampleName ","}}
Input(SampleName) | Output |
---|---|
John Mary Paul | John,Mary,Paul |
Example 2:
{{join employees lookup="Name.Firstname"}}
Input(employees.Name) | Output |
---|---|
Firstname Lastname Peter Parker Tony Stark Steve Rogers | Peter,Tony,Steve |
Replace
Syntax: {{replace input match_str replace_str}}
( Here the match_str can be either a text or regex)
Example | Input | Output |
---|---|---|
| Input to_replace replacer MaryRoss Ross Jane | MaryJane |
| Ragax | Regex |
Regex
Syntax: {{regex pattern flags}}
(No flags are set by default).
Example | Input | Output |
---|---|---|
|
|
|
|
|
|
Strip
Syntax: {{strip input match_str side=side}}
Example | Input | Output |
---|---|---|
|
|
|
|
|
|
Split
Syntax: {{split input separator}}
(separator can either be text or Regex)
Example | Input(FieldName) | Output |
---|---|---|
| John,Doe,Cleveland |
|
| John12Doe34Cleveland |
|
Sort
Syntax: {{sort content order=order lookup="lookup_key"}}
Example 1:
{{#each (sort cost order="desc")}}
{{this}}
{{/each}}
Input | Output |
---|---|
750 150 500 | 150 500 750 |
Example 2:
{{#each (sort items lookup="price" order="asc")}}
{{name}} is available at {{price}} per {{unit}}.
{{/each}}
Input | Output |
---|---|
Name Price Unit Pen 20 5 Pencil 10 4 Book 25 3 | Pencil is available at 10 per 4. Pen is available at 20 per 5. Book is available at 25 per 3. |
Note : The helpers Split, Sort and Regex are Sub-Expression only helpers which can be used with loop helpers like each
and list
Filter
The filter
helper can be used to refine lists by applying specific conditions, effectively narrowing down the data to what's most relevant. The syntax for the filter
helper is {{filter items condition}}
, where items
is the list to be filtered and condition
is the criteria applied to each item. Conditions can range from straightforward comparisons, like (department == "Sales")
, to more complex expressions like ((LeadScore > 60 and LeadScore <= 80) and LeadRole == "vp" and LeadIndustry == "Healthcare")
. Here are a few examples showcasing the versatility of the filter
helper:
Print a list of employees from Sales department and their salaries:
Filter can be combined with sort to handle more advanced use-cases: For example, to print list of products in inventory that are priced higher than or equal to 50$ in descending order of price:
Filtering a list of events to include only those happening in December
Above example can be modified further to make the month dynamic too, but we need to use Lookbacks to achieve the same:
Filtering a collection of books to display only those published after the year 2000
Filter a dataset to exclude items marked as inactive
Filter Leads that are VPs in Healthcare with lead score greater than 80
Print Leads that are from Healthcare or Pharma industry with lead score higher than 80 but lower than 95, in descending order of lead score.
These examples demonstrate the filter
helper's capability to perform both simple and complex data filtering within a template, making it an essential tool for crafting dynamic content.
Var
The var
helper is a powerful tool designed for both storing and retrieving data within templates, enabling dynamic variable use. This functionality allows users to assign values to tokens directly within their documents through a simple syntax: {{var "token" value}}
. For instance, assigning a numerical value or even transferring values between tokens is effortlessly done using {{var "cost" 500}}
or {{var "amount" MRP}}
, respectively. Retrieving the stored data is just as straightforward; by calling {{var "token"}}
, the value assigned to the specified token is seamlessly inserted into the document.
Storing Data
Syntax: {{var "token" value}}
Example | Output |
---|---|
| Here the token cost is assigned a value of 500. |
| Here the token price is assigned a value of 7599. |
| Here the value in token MRP is assigned to the token amount. |
Retrieving Data
Syntax: {{var "token"}}
Example | Output |
---|---|
| 500 |
| 7599 |
Pad helper
Pad helper fills up the input to the desired width by adding a single character repeatedly either at the beginning or at the end.
Syntax: {{pad number output_width pad_with='character' style='prefix|suffix'}}
Example 1:
{{pad number 7}}
Input | Output |
---|---|
123 | 0000123 |
Example 2:
{{pad number 9 pad_with='#' style='suffix'}}
Input | Output |
---|---|
123456 | 123456### |
Aggregate
Aggregate functionality helps to accumulate data from a collection of items to return a single result (like adding numbers in a list). It is useful in scenarios like invoice processing, where it can compute totals such as the total number of items sold, invoice sub total, grand total, factoring in discounts, etc.
Example: Consider a case where you want to generate an invoice which can auto-calculate quantity sold, sub total and grand total. Assuming InvoiceLineItems
is the field which contains all line items where each line item contains properties: name
, qty
, unit_price
and discount
.
To calculate the total number of items sold as part of this invoice, we need to add qty
from each line item. It can be done using:
{{aggregate InvoiceLineItems formula="qty" operation="add"}}
To compute the invoice total before applying any discounts, we need to add the result of qty * unit_price
from each line item. This can be achieved using:
{{aggregate InvoiceLineItems formula="qty * unit_price" operation="add"}}
To compute discounted invoice total where discounts are applicable as percentage for each line item separately, we need to add the result of qty * unit_price * (1 - discountPercentage / 100)
for each line item.
{{aggregate InvoiceLineItems formula="qty * unit_price * (1 - discountPercentage / 100)" operation="add"}}
Note that each operator inside formula should have a leading and trailing space to work accurately. For example "qty*unit_price" will not work, only "qty * unit_price" will. This limitation may be addressed in one of our future updates.
Concat
Syntax : {{concat string1 string2 ....}}
Example:
{{insert_image (concat "https:" url) 300 300}}
Input:
//raw.githubusercontent.com/tiholic/exif-orientation-examples/master/Portrait_0.jpg
Output:
Group By
Group by helper groups the data with the value of lookup key as grouping criteria.
Syntax: {{group_by FieldName lookup="lookup_key"}}
Key
and items
can be accessed from inside the iterator(#each
or #list
). Key
contains value of "lookup_key"
for the current record, items
contain the records which are present under current group.
Example 1:
Input: (JSON)
Output :
In the above example,
"TL" and "PM" are the group
keys
.items
corresponding to the key "TL" are :{ "role": { "code": "TL" }, "name": { "first": "Emma" } }
{ "role": { "code": "TL" }, "name": { "first": "Chris" } }
{ "role":{ "code": "TL" }, "name": { "first": "Dave" } }
items
corresponding to the key "PM" are:{ "role": { "code": "PM" }, "name": { "first": "Jenn" } }
{ "role": { "code": "PM" }, "name": { "first": "Matt" } }
Example 2:
Input: (JSON)
Output:
In the above example,
"New York", "Las Vegas" and "Chicago" are the group
keys
.Number of
items
corresponding to the key "New York" are 3.Number of
items
corresponding to the key "Las Vegas" are 3.Number of
items
corresponding to the key "Chicago" is 1.
Inserting a link
To insert a dynamic URL into your document.
Format: {{insert_link url text=text}}
Example | Input | Output |
---|---|---|
{{insert_link url}} | url=https://docupilot.app/ | |
{{insert_link url text=url_text}} | url=https://docupilot.app/ url_text="Example" | |
{{insert_link url text="Click Here"}} | url=https://docupilot.app/ |
Hyperlink style customization in Word documents
Inserted hyperlinks follow the source style in Builder templates. In case of Word Document templates, style customization can be done by opening Format > Styles > Search and select "Hyperlink" > click Modify > Update to desired style and click Ok
URL encode
URL encode helper replaces special characters inside a URL with encoded text.
Syntax : {{url_encode URL is_url=true|false}}
Example1:
Syntax in Template
Input sent to the template (JSON):
Generated Output:
Example2:
Syntax in Template
Input sent to the template (JSON):
Generated Output:
URL decode
URL decode helper decodes encoded URLs into pre-encoded forms.
Syntax : {{url_decode URL is_url=true|false}}
Example1:
Syntax in Template
Input sent to the template (JSON):
Generated Output:
Example2:
Syntax in Template
Input sent to the template (JSON):
Generated Output:
Encoding or decoding a URL depends on the value of the parameter 'is_url'. If the value is true, only the query parameter part of the complete URL is encoded/decoded else, the whole of the URL is encoded/decoded. The Default value of is_url is set as false.
Rand
Rand will return a random value between the min and max values passed.
Syntax: {{rand min max}}
Example | Input | Output |
---|---|---|
{{rand min max}} | min: 2 max: 500 | could be any random number between 2 and 500 Ex: 436.89318 |
{{round (rand min max)}} | min: 2 max: 500 | could be any random integer value ex: 437 |
rand returns a decimal value between the given min and max. Use round along with rand to get an integer value.
As Number
As Number converts any given input to a valid number.
Syntax: {{as_number FieldName}}
Example | Input | Output |
---|---|---|
{{as_number value}} | value: "23.000"(string) | 23(numerical value) |
{{#if (as_number input_value) "<=" 100}} Value is less than 100. {{else}} Value is greater than 100. {{/if}} | input_value: "98.767"(string) | Value is less than 100. |
{{#if (as_number input_value) "<=" 100}} Value is less than 100. {{else}} Value is greater than 100. {{/if}} | input_value: "101.9876"(string) | Value is greater than 100. |
As String
As String converts any given input to a valid string.
Syntax: {{as_string FieldName}}
Example | Input | Output |
---|---|---|
{{as_string value}} | value: 234.987 (numerical value) | "234.987" (String) |
{{#if (as_string input_value) "==" "23.000"}} Success {{else}} Fail {{/if}} | input_value: "23.000"(string) | Success |
{{#if (as_string input_value) "==" "23.000"}} Success {{else}} Fail {{/if}} | input_value: "23.00"(string) | Fail |
As Boolean
As Boolean converts any given input into Boolean values 0(False) and 1(True).
String: {{as_boolean FieldName}}
Example | Input | Output |
---|---|---|
{{as_boolean value}} | value: 348 | 1(True) |
{{as_boolean input_value}} | input_value: 0 | 0(False) |
{{#if (as_boolean input_value)}} Input received. {{else}} Input is empty. {{/if}} | input_value: 123.9 | Input received |
Last updated