Working with handlebars can be challenging, especially when dealing with complex syntax and semantics of the templating language. Any difficulty in interpreting these expressions might lead to errors and issues in the code.
The Celigo AI component allows you to create handlebars expressions using simple English language prompts and explain such expressions in simple language. Describe what you would like the expression to do in plain language, and Celigo AI will generate a suggested template for you that you can refine as required.
When you define your requirement in a plain English prompt, Celigo AI will generate the corresponding handlebars expression for you in the editor. You can even describe handlebars that include multiple fields and complex use cases. Be sure to write your prompt in plain English with clear logic, as you might explain it to a coworker.
After the results of your prompt are retrieved, you can enter additional prompts that describe additional changes to the expression that Celigo AI might not have fully understood. All previous prompts are saved and can be viewed or copied until you click Reset conversation or close the editor.
Note
After you reset the conversation, to write new expressions, remove the existing handlebar template.
Click thumbs up or down for each prompt to indicate if the response provided by Celigo AI was helpful or not.
Sample JSON |
Prompt |
AI-generated handlebars template |
Output |
---|---|---|---|
{ "animal": "canine", "type": "dog, wolf, extant grey wolf" } |
Capitalize all in type |
{{capitalizeAll type}} |
Dog, Wolf, Extant Grey Wolf |
Sample JSON |
Prompt |
AI-generated handlebars template |
Preview |
---|---|---|---|
{ "first_name": "John", "last_name": "Doe", "gender": "Male", "date_of_birth": "1990-05-15", "email": "johndoe@example.com", "phone_number": "+1 (555) 555-5555", "address": { "street_address": "123 Main Street", "city": "Anytown", "state": "CA", "postal_code": "12345", "country": "United States" } } |
Need to concatenate address fields for shipping field |
{{address.street_address}}, {{address.city}}, {{address.state}}, {{address.postal_code}}, {{address.country}} |
123 Main Street, Anytown, CA, 12345, United States |
Can you add your full name as well as ZIP code at last |
{{address.street_address}}, {{address.city}}, {{address.state}} {{address.postal_code}}, {{address.country}} - {{first_name}} {{last_name}} |
123 Main Street, Anytown, CA 12345, United States - John Doe |
|
Remove country |
{{address.street_address}}, {{address.city}}, {{address.state}} {{address.postal_code}} - {{first_name}} {{last_name}} |
123 Main Street, Anytown, CA 12345 - John Doe |
Sample JSON |
Prompt |
AI-generated handlebars template |
Preview |
---|---|---|---|
{ "user": { "id": "123456789", "name": "John Doe", "email": "johndoe@example.com" }, "orders": [ { "order_id": "987654321", "date": "2023-06-28", "items": [ { "product_id": "12345", "name": "Example Product 1", "price": 19.99, "quantity": 2 }, { "product_id": "54321", "name": "Example Product 2", "price": 9.99, "quantity": 1 } ], "total": 49.97, "status": "Delivered" }, { "order_id": "123456789", "date": "2023-06-25", "items": [ { "product_id": "98765", "name": "Example Product 3", "price": 14.99, "quantity": 3 } ], "total": 44.97, "status": "Delivered" } ] } |
Multiply price and quantity |
{{#each orders}} {{#each items}} Total price for {{name}}: {{multiply price quantity}} {{/each}} {{/each}} |
Total price for Example Product 1: 39.98 Total price for Example Product 2: 9.99 Total price for Example Product 3: 44.97 |
Celigo AI provides an explanation of any part of the handlebars expression that you select in the text. Select the part of the expression that you want Celigo AI to explain, and click Explain selection. Celigo AI will generate an explanation for the selected expression. The selected lines remain highlighted until you close the explanation window. You can reposition the explanation window as needed.
Sample JSON |
Handlebars template |
Explain selection |
---|---|---|
{ "animal": "canine", "type": "dog, wolf, extant grey wolf" } |
{{capitalizeAll type}} |
The `capitalizeAll` helper is used to capitalize the first letter of each word in the `type` variable. |
Sample JSON |
Handlebars template |
Explain selection |
---|---|---|
{ "first_name": "John", "last_name": "Doe", "gender": "Male", "date_of_birth": "1990-05-15", "email": "johndoe@example.com", "phone_number": "+1 (555) 555-5555", "address": { "street_address": "123 Main Street", "city": "Anytown", "state": "CA", "postal_code": "12345", "country": "United States" } } |
{{address.street_address}}, {{address.city}}, {{address.state}}, {{address.postal_code}}, {{address.country}} |
`{{address.street_address}}` refers to the `street_address` property of the `address` object. It displays the street address of the address. |
Sample JSON |
Handlebars template |
Explain selection |
---|---|---|
{ "user": { "id": "123456789", "name": "John Doe", "email": "johndoe@example.com" }, "orders": [ { "order_id": "987654321", "date": "2023-06-28", "items": [ { "product_id": "12345", "name": "Example Product 1", "price": 19.99, "quantity": 2 }, { "product_id": "54321", "name": "Example Product 2", "price": 9.99, "quantity": 1 } ], "total": 49.97, "status": "Delivered" }, { "order_id": "123456789", "date": "2023-06-25", "items": [ { "product_id": "98765", "name": "Example Product 3", "price": 14.99, "quantity": 3 } ], "total": 44.97, "status": "Delivered" } ] } |
{{#each orders}} {{#each items}} Total price for {{name}}: {{multiply price quantity}} {{/each}} {{/each}} |
|
Comments
Please sign in to leave a comment.