Help Desk

Submit a ticket My Tickets
Welcome
Login

Handlebars vs JSON

Is there any advice on when NOT to use Handlebars?

Handlebars seems more powerful and flexible than the JSON Bizapps like Array to CSV but obviously there is a trade off in the complexity of building the handlebars logic.

Would Handlebars be faster than JSON Array to CSV at runtime?

  • Hi James,

    If you are just trying to convert to CSV, then I would recommend the JSON to CSV Commands as creating a template would be unnecessary.  If you need the output of the JSON conversion to be in something other than a CSV format such as XML, that is when the use of Handlebars would be more applicable.  This article provides you a good example of how to use a Handlebars template with a JSON object:

    https://support.onecloud.io/support/discussions/topics/48000558868

    Let us know if this answers your question.

    Tony

  • There are areas from what I have seen that handlebars gives you extra flexibility:

    • The JSON to CSV and Array to CSV commands require you to know the exact number of columns you want to create whereas with Handlebars you have greater potential to manipulate the template at runtime
    • Handlebars gives you an easier ability to do loops within loops and refer to parent values via ../ as opposed to doing iterations e.g.
    {{#each sheet.rows}}
      {{#each cells}}
         {{../rowNumber}} , {{value}} 
      {{/each}}
    {{/each}}

    So the JSON bizapps are great but less flexible. Handlebars gives you loads of flexibility but requires more in depth knowledge for the developer. 

Login to post a comment