Help article on handlebars integration? | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

There are lots of libraries available like:

https://json2html.com/

Displaying data from a flat JSON file on a Handlebars.js template file rendered with AJAX. · GitHub

AngularJS

VueJs (e.g.javascript - Fliter Json to HTML using Vue JS - Stack Overflow )

Unlike using libraries you can use do with jquery or javascript if structure is not complex and repetative.

6 replies

arunpatidar
Community Advisor
Community Advisor
August 16, 2018

Hi,

Not sure if you are looking for client side handlebar js or server side handle bar integration.

Check below if helps

SCF Handlebars Helpers

https://handlebarsjs.com/

Handle bar & AEM server side integration

http://aempodcast.com/2015/javascript/server-side-handlebars-aem/#.W3XnmmaB1AY 

Arun Patidar
August 16, 2018

Hi Arun,

I want to render json response received from ajax using any templating language. I think we can't call sightly template from ajax success method and handlebar could come to rescue here. I want to pass json response to handlebar template and then render converted html on page.

Thanks,

Rajeev

August 16, 2018

Below is the scenario..

$.ajax({

        type: 'GET',

        url: 'test.json',

        data: { get_param: 'value' },

        dataType: 'json',

success: function (data) {

   //1.  use any template to convert json response to html block

   //2. Set the response on page(this can be done using jquery once html block is available from template.

});

}

});

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
August 16, 2018

There are lots of libraries available like:

https://json2html.com/

Displaying data from a flat JSON file on a Handlebars.js template file rendered with AJAX. · GitHub

AngularJS

VueJs (e.g.javascript - Fliter Json to HTML using Vue JS - Stack Overflow )

Unlike using libraries you can use do with jquery or javascript if structure is not complex and repetative.

Arun Patidar
August 16, 2018

Thanks Arun.

I will prefer library so that JS & html are separated. Response data is complex and therefore having html template would be a better choice.

json2html seems to be too raw and basic api compared handlebar.

Thanks for the pointers. I will try to integrate handlebar using custom clientlib and see if I encounter any issues during this process.

Thanks,

Rajeev

August 16, 2018

Arun,

Just last question - Can we levarage HTL template to render the json response from ajax?