Templating Techniques for Scenarios

Handle data like a pro πŸ§™β€β™‚οΈ

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 "β†’'

Encode URI

Executes encodeUriComponent() for the string

Decode URI

Decodes the string encoded by encodeURIComponent

Convert to JS-multiline

Useful feature for applying regex.

Escape JSON

Formatting date

Hint: You may also use moment().format()

Learn more about date/time formats.

Handling boolean properties

Nesting arrays of linked objects

If a property has arrayLink type, we can nest its objects as follows:

Handling arrays

Also, we can avoid empty elements of an array:

Check the tips for advanced working with Arrays.

Handling JSON

JSON templating

Let's a property has json-type, and equals to:

We can address to its properties as follows:

Remember, that if JSON contains array of objects, you have to apply JS SDK methods (here it is an instruction).

JSON as a JS object

Also, you can apply JS for parsing JSON, handle it as a js-object (don't forget to turn on JS-evaluating)

Lodash for JSON parsing

Using now, today, +/– days

For using this feature you have to turn on Evaluate as a JS-expression

Using Lodash

You can apply Lodash in expressions. Lodash is a modern JavaScript utility library delivering modularity, performance & extras.

Last updated

Was this helpful?