Articles in this section

Handlebars syntax

Functional implementation relies heavily on the proper use of handlebars curly braces. You may need an overview of handlebars expressions , JSON basics, or a helper reference for more complex functionality.

Typographical Conventions

Item

Description

{{ }}

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). For handlebars used in Postgres DB queries, this would escape the characters specific to the Postgres DB: https://www.postgresql.org/docs/9.2/sql-syntax-lexical.html#:~:text=PostgreSQL%20also%20accepts%20%22escape%22%20string,e.g.%2C%20E'foo'

{{{ }}}

Handlebars triple-braces does not perform any encoding and preserves the characters as entered in the sample data. Use triple-braces if your field values have already been URL encoded.

{{{{ }}}}

Handlebars raw block.

{{name}}

Handlebars expression.

{{first.name}}

Dot-notation for nested objects.

\{{escaped}}

Using a backslash as a leading character before an expression

prints the entire {{excodession}} text (without parsing the expression itself) to output (with braces).

Template

The handlebars expressions and/or helpers chained in a block or

sequence.

Context

JavaScript Object Notation (JSON ) files are referred to as "Context" when using Handlebars. These are the files that you upload in integrator.io or sample data used to render outputs for testing for your JSON files.

Output

Shows the result of the template after parsing the context.

[customer name] [Carrier Name (Shiphawk)]

Use square brackets to reference field names or values that contain spaces.

Code that appears between the curly braces {{field}} are known as “expressions” in Handlebars. Handlebars expressions may be used for:

  • Mapping Export and Import application fields;

  • Performing dynamic arithmetic calculations on the values being exported;

  • Performing dynamic encoding and decoding of data during integration.

Handlebars expressions use dot-notation to access object properties. The expression in the first example is set to look up the value in the “title” field name within the “library” object or parent property. In the second example, the handlebars expression uses double quotes (" ") to return data in a JSON format. In the third, the handlebars expression uses helpers to manipulate the data. If you’re using a helper within a double quotes string (" ") you must change any double quotes inside the helper to single quotes (' ') ). In this case, you’re changing {"rocketID":"{{getValue "record.rocket" "defaultValue"}}"} to {"rocketID":"{{getValue 'record.rocket' "defaultValue"}}"}.

Template

Context

Output

{{library.title}}

{
  "library": {
    "album": "The Sound",
    "title": "Danube Incident",
    "artist": "Lalo Schifrin"
  }
}

Danube Incident

{{"shipName": "{{record.name}}"

{"record": {
  "fairings": {
    "reused": false,
    "recovery_attempt": false,
    "recovered": false,
    "ships": []
  }, 
  {
    "launchpad": "5e9e4502f5090995de566f86",
    "flight_number": 1,
    "name": "FalconSat",

shipName: FalconSat

{"rocketID":"{{getValue 'record.rocket' "defaultValue"}}"}

{"record": {
  "fairings": {
    "reused": false,
    "recovery_attempt": false,
    "recovered": false,
    "ships": []
  },
 "rocket": "5e9d0d95eda69955f709d1eb",

rocketID: 5e9d0d95eda69955f709d1eb