Handlebars array rendering issue in AEM | Community
Skip to main content
Level 2
April 24, 2019
Solved

Handlebars array rendering issue in AEM

  • April 24, 2019
  • 6 replies
  • 3830 views

Hi,

I am new to AEM and facing one strange issue with Handlebars js support in AEM. I have created a simple component with .hbs file. Within hbs file I am simply rendering the JSON array using handlerbars iteration mechanism. It does iterate the array but it does not print the actual value of any of its object element.

Handlebars code and String array

Result of the page rendering. It does not print the value of "linkText". However it does print the whole object using {{this}}.

I am not sure what's wrong here as this handlerbars code perfectly works when run outside the AEM/CRXDE context.

Quick reply to this issue would really be appreciated.

Thank you in advance

Regards,

Ganesh

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 Gaurav-Behl

Use cq.handlebars (/libs/clientlibs/social/thirdparty/handlebars) or download js from https://handlebarsjs.com/ and embed it in your clientlibs otherwise use CDNjs url in headlibs

Examples are available in social/community code or at https://handlebarsjs.com/

6 replies

smacdonald2008
Level 10
April 24, 2019

If you look at the Weekend tutorial, which is a great guideline for AEM development, there is no mention of using this framework. Adobe recommends HTL for component development. Core components are all HTL based.

Level 2
April 24, 2019

Hi Scott,

Thank you for your reply. As per this Adobe documentation Social Component Framework  and SCF Handlebars Helpers it seems that AEM does support handlerbars js. But it strange that only iteration mechanism doesn't work properly but all other handlebars features does work.

Regards,

Ganesh

smacdonald2008
Level 10
April 24, 2019

That could be a bug. I have never used it to develop components. I will check with the Community product team to see if anyone knows about this,

Gaurav-Behl
Level 10
April 24, 2019

Make sure that if you are using client side version of hbs, then you have the required hbs library/dependencies loaded on that page. If you use it outside social framework, then you'd need to include it explicitly on your page/component/template based on your use case.

Level 2
April 25, 2019

Thanks Gaurav for your reply. Could you tell me what library or dependencies it required on client side? If you could show me a sample code then that would be really great.

Thanks in advance.

Gaurav-Behl
Gaurav-BehlAccepted solution
Level 10
April 25, 2019

Use cq.handlebars (/libs/clientlibs/social/thirdparty/handlebars) or download js from https://handlebarsjs.com/ and embed it in your clientlibs otherwise use CDNjs url in headlibs

Examples are available in social/community code or at https://handlebarsjs.com/