Turn off smart field inputs to use the following techniques
Escaping special characters
{{#escape}}{{name}}{{/escape}}
// if {{name}} is 'aaaa"aaaa', this operator will add
// a backslash before each special character for escaping them.
// The result of templating will be: 'aaaa\"aaaa'
Removing line breaks
{{#stripNewLine}}this new
line{{/stripNewLine}}
// operator removes line breaks
// result of templating will be: 'this new line'
Escaping line breaks (useful for JSONs)
This operator escapes \n (line breaks). Thanks to that a multiline JSON can be sent in the http-request body as follows:
//{{json}} is a field value with multiline json
//body of the http-request:
{"key":"{{#escape}}{{#escapeNewLine}}{{json}}{{/escapeNewLine}}{{/escape}}"}
Replace "→'
{{#replaceDoubleQuotes}}hello "there'{{/replaceDoubleQuotes}}
// result hello 'there'
// shows if is_vip == true
{{#is_vip}}vip{{/is_vip}}
// shows if is_vip == false
{{^is_vip}}not vip{{/is_vip}}
Nesting arrays of linked objects
If a property has arrayLink type, we can nest its objects as follows:
// {{books_ids}} — field type of arrayLink
// {{title}} and {{year}} — the fields of linked objects
{{#books_ids}}
– {{title}}, {{year}}
{{/books_ids}}
// If such {{books_ids}} contains, for example, three links,
// such a construction will result as follows:
// – Life of Samuel Johnson, 1791
// - Crime and Punishment, 1866
// - The Sun Also Rises, 1927
Handling arrays
// We can template the Array field, iterationg its elements:
{{#arr}}
- {{.}}
{{/arr}}
// if {{arr}} == a,b,c
// result of templating will be:
// - a
// - b
// - c
Also, we can avoid empty elements of an array:
{{#musketeers}}
{{#.}}
- {{.}}
{{/.}}
{{/musketeers}}
// {{musketeers}} == "Athos", "Aramis", "", "D'Artagnan"
// result of templating will be:
// - Athos
// - Aramis
// - D'Artagnan
now == current date and time
today == current date, time 00:00
now -1 days == yesterday
today +N days == N days after today
now +10 minutes +15 seconds == 10 minutes and 15 seconds after the current moment
Using Lodash
You can apply Lodash in expressions. Lodash is a modern JavaScript utility library delivering modularity, performance & extras.
// some examples:_.defaults({ 'a':1 }, { 'a':3,'b':2 });// → { 'a': 1, 'b': 2 }_.partition([1,2,3,4], n => n %2);// → [[1, 3], [2, 4]]_.difference([2,1], [2,3]);// => [1]