HandlebarsJS not working properly under AEM (a tag disappearing) | Community
Skip to main content
jayv25585659
Level 8
March 19, 2018

HandlebarsJS not working properly under AEM (a tag disappearing)

  • March 19, 2018
  • 1 reply
  • 1652 views

So I have a similar code in my HTL (please click link for a non-AEM test page)

<div id="base">

  <a href="{{link}}">{{text}}</a><br>

</div>

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.11/handlebars.min.js" ></script>

<script type="text/javascript">

   var source  = document.getElementById("base").innerHTML;

   var template = Handlebars.compile(source);

   var context = {text: "My New Post", link: "https://www.google.com"};

   var html  = template(context);

   console.log(html);

</script>

My issue is that under AEM, the a tag disappears. If I change the href property to

<a href="##">{{text}}</a>

it works fine.

I've tried using the built-in HandlebarsJS inside AEM (/etc/clientlibs/granite/handlebars) via clientlibs and the external HandlebarsJS (via CDN) and they are not working.

If you try the test link (see 1st line), handlebars is working properly outside of AEM.

Any ideas? Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

kautuk_sahni
Community Manager
Community Manager
March 21, 2018

Are you following any documentation to achieve this? here is the one:- SCF Handlebars Helpers

Note:- Make sure to install the latest latest Communities feature pack.

Kautuk Sahni