#startsWith helper renders the block if the test string begins with the specified prefix. If it does not match, the {{else}} block is rendered. Usage {{#startsWith prefix testString}}Block if match{{else}}Fallback{{/startsWith}} prefix (required): the prefix to check for testString (required): string to test against. Examples 1.Check if a greeting starts with “Hello” {{#startsWith “Hello” record.greeting}}Match!{{else}}No match{{/startsWith}}… Continue reading Handlebars – #startsWith helper
Tag: Celigo Handlebars
Celigo – Handlebars overview
Handlebars is a simple templating language. Handlebars templates look like regular text with embedded handlebars expressions. Expressions Expressions are functions that are named according to the function they perform. They can accept and pass arguments to other functions or expressions, modify the output, and perform a host of other functions. Handlebars helpers will modify the… Continue reading Celigo – Handlebars overview
Exclude the JSON row structure from files
When creating the JSON files the JSON data is enclosed in square brackets. The opening and closing square brackets are the defining characteristics of a JSON row structure. When we group the export data, the data passes through the rest of the flow in row structure. These square brackets can be removed by using the below… Continue reading Exclude the JSON row structure from files
Handlebar syntax for curly braces
{{ }} – Handlebars double-braces will URL encode characters that are able to be URL encoded. The double-braces themselves do not display in output (escaped). For example, you could use double-braces for an HTTP URI. This would automatically perform the URL encoding for any escaped characters (such as <, > , or space). In the… Continue reading Handlebar syntax for curly braces
Handlebar – Add function
Adds all numeric values (integers, floats, or decimals). Parameters can either be a field that returns a number value or a hard-coded number value. {{add number1 number2 ….}} number1: Numeric field or hard-coded integer, float, or decimal. number2: Numeric field or hard-coded integer, float, or decimal. Examples: Template: {{add “2” “5” “2”}} output: 9 Template:… Continue reading Handlebar – Add function
Handle white space
Whitespace placed before any symbol inside the handlebars will cause an error. Correct: {{expression}}{{dateFormat}} Incorrect: {{ expression}}{{ dateFormat}} // note the leading whitespace Error: {{expression {{field}} // second set of opening braces seen as new expression
Handlebars custom helper – replace
Replaces all the occurrences of the specified letter in a string with another letter. Ex: Template – {{replace cases “&” “and”}} Context – {“cases”: “these & those & some other cases”} Output – these and those and some other cases Ex: Template – {{replace $item[*].price “,” “”}} Context – 12,500 Output – 12500
How to add a handlebar inside a handlebar
Use a bracket to separate the handlebars. Please check the following for an example {{#if line_items.0.properties.0.value }}{{#contains line_items.0.properties.0.value “Pre Order”}} {{dateFormat ‘MM/DD/YYYY’ (replace line_items.0.properties.0.value “Pre Order | Due In ” ”) ‘DD/MM/YYYY’}}{{/contains}}{{/if}}