Templates are reusable pieces of text that can use variable values to affect their appearance. The variables are accessed using special handlebars syntax. Apart from variables, the template syntax also provides simple flow control.

To better illustrate how the templates look and function, here’s an example:

Hello, dear {{record.name}}!

This is a mail from {{app.config.companyName}}, writing to let you know of our recent policy changes.
{{#if param.detail}}
These changes include …………
{{/if}}

Best regards,
{{app.config.companyName}}

Helpers

Template commands are called helpers and are placed between {{double mustaches}}. There are a number of helpers available:

Helpers available in actions (such as when sending emails or SMS):

CommandDescriptionExample
appIconUrlReturns the URL of the app’s icon{{appIconUrl}}
documentReturns the download link of a document record{{document record}}
stringAccess localization strings.{{string “Hello World”}}
formatNumberFormats a number using dojo number formatting{{formatNumber 10 2}}
getViewURLReturns the URL to the specified view. Optionally provide a record to populate the view’s forms{{getViewURL “view_0” record “myMobileInterface”}}
{{getViewURL “list_data” null “desktop”}}
startsWithTrue if the specified string starts with the specified value{{startsWith str “value”}}
compareCompares two values.{{compare 10 “==” 5}}
{{compare 10 “>=” record.number}}
arithmeticOperatorPerforms arithmetic operations{{arithmeticOperator record.number “+” 10
formatDateFormats a date{{formatDate record.Date ‘short’ ‘long’}}
{{formatDate record.Date ‘yyyy-MM-dd’ timezone=”UTC”}}
formatTimeAgoCreates a string describing a moment that happened some time units ago. E.g. “15 minutes ago” or “2 years ago”{{formatTimeAgo record.When}}
documentUrlCreates a URL to a document-record{{documentUrl record}}
fileCreates a file link{{file record}}
resourceCreates a link to a resource{{resource “testResource”}}
concatConcatenates two strings{{concat “string1” “string2”}}
capitalizeCapitalizes the first letter of a string{{capitalize “hello”}}
decapitalizeDecapitalizes the first letter of a string{{decapitalize “Hello”}}
toUpperCaseConverts the entire string to upper case{{toUpperCase “hello”}}
toLowerCaseConverts the entire string to lower case{{toLowerCase “HELLO”}}
monthNameGets the month name of the specified date{{monthName “20161203”}}
inlineImage{{inlineImage record}}

Helpers available in views (such as the HTML widget):

CommandDescriptionExample
stringAccess localization strings.{{string “Hello World”}}
formatNumberFormats a number using dojo number formatting{{formatNumber 10 2}}
formatCurrencyFormats a number using dojo currency formatting
startsWithTrue if the specified string starts with the specified value{{startsWith str “value”}}
compareCompares two values.{{compare 10 “==” 5}}
{{compare 10 “>=” record.number}}
arithmeticOperatorPerforms arithmetic operations{{arithmeticOperator record.number “+” 10
formatDateFormats a date using dojo date formatter{{formatDate “20161203”}}
getWeekDayReturns the weekday name of the specified date{{getWeekDay “20161203”}}
formatTimeFormats time{{formatTime “10:25”}}
formatTimeAgo
documentUrlCreates a URL to a document-record{{documentUrl record}}
fileCreates a file link{{file “path”}}
resourceCreates a link to a resource{{resource “testResource”}}
concatConcatenates two strings{{concat “string1” “string2”}}
capitalizeCapitalizes the first letter of a string{{capitalize “hello”}}
decapitalizeDecapitalizes the first letter of a string{{decapitalize “Hello”}}
toUpperCaseConverts the entire string to upper case{{toUpperCase “hello”}}
toLowerCaseConverts the entire string to lower case{{toLowerCase “HELLO”}}
monthNameGets the month name of the specified date{{monthName “20161203”}}
inlineImage{{inlineImage record}}

Several more helpers are available on the handlebars website.

Additionally, for templates used in actions, the following data is available:

CommandDescriptionExample
recordAccess the current record. Use ‘.’ to access attributes or relations{{record.name}}
{{record.owningUser}}
appAccess the current app. From the app you can access models, config parameters, etc.{{app.config.paramName}}