Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

iHub cloud used https://handlebarsjs.com/ as template language.

This is an extension to Mustache and have few smart functions.

Smart functions

{{{toCSV list 'propertyName' 'quotes'}}}

Creates a csv of the array.
example{{{toCSV list 'name' '\"'}}} would take an array of object and use the name property with double quotes to create a csv, like this "Peter","Rickard"

{{toJSON object}} or {{JSONstringify object}}

Runs JSON.stringify(object) on the object.
Good to use in cases where you get an output like [object Object],[object Object]

example and object like this {payload:[{ value: "foo" },{ value: "bar" }]} with the mustache {{{toJSON payload}}} would resolve in [{"value":"foo"},{"value":"bar"}] instead of [object Object],[object Object]

"{{{flowVarMerge output _flow 'property_in_flow' 'new_name_in_scope'}}}"

This mustache function is a special one used mainly to insert flow variables into the output object. The output object is any object in the scope, usually payload or scope.something

Example if the payload variable is a list like below

[{"name":"A","id":"1"},{"name":"B","id":"2"}]
and you have a _flow variable collected in earlier actions like this:
["A":['n1','n2'],"B":['n3']]

Then when using this syntaxr

"{{{flowVarMerge payload _flow 'name' 'newProp'}}}"

The function will output

[{"name":"A","id":"1","newProp":['n1','n2']},{"name":"B","id":"2","newProp":['n3']}]

See all Math functions

"{{#eq 1 1}}YES{{/eq}}" tests if 1 eq 1 and return YES

{{add 1 1}} results in 2

See all Dates functions

Moment date functions

{{date "5 years ago" "YYYY"}} resolves current year - 5

{{moment format="HH:mm:ss"}} 16:34:56

See all helpers

Handlebars is extended with all the helpers in the link

  • No labels