Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

Help article on handlebars integration?

Avatar

Level 4

Do we have any help article for handlebars integration in aem?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

6 Replies

Avatar

Community Advisor

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

Avatar

Level 4

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

Avatar

Level 4

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.

});

}

});

Avatar

Correct answer by
Community Advisor

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

Avatar

Level 4

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

Avatar

Level 4

Arun,

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