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.
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: |
|
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. |
|
Handlebars expression. |
|
Dot-notation for nested objects. |
|
Using a backslash as a leading character before an expression prints the entire {{excodession}} text (without parsing the expression itself) to output (with braces). |
|
The handlebars expressions and/or helpers chained in a block or sequence. |
|
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. |
|
Shows the result of the template after parsing the context. |
|
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": { "album": "The Sound", "title": "Danube Incident", "artist": "Lalo Schifrin" } } |
|
|
{"record": { "fairings": { "reused": false, "recovery_attempt": false, "recovered": false, "ships": [] }, { "launchpad": "5e9e4502f5090995de566f86", "flight_number": 1, "name": "FalconSat", |
|
|
{"record": { "fairings": { "reused": false, "recovery_attempt": false, "recovered": false, "ships": [] }, "rocket": "5e9d0d95eda69955f709d1eb", |
|