Templating Techniques for Scenarios
Handle data like a pro π§ββοΈ
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
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
Using Lodash
You can apply Lodash in expressions. Lodash is a modern JavaScript utility library delivering modularity, performance & extras.
Last updated
Was this helpful?