HandlebarsJS not working properly under AEM (a tag disappearing)

Avatar

Avatar

jayv25585659

Avatar

jayv25585659

jayv25585659

19-03-2018

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

Replies

Avatar

Avatar

kautuk_sahni

Community Manager

Total Posts

5.7K

Likes

1.0K

Correct Reply

1.1K

Avatar

kautuk_sahni

Community Manager

Total Posts

5.7K

Likes

1.0K

Correct Reply

1.1K
kautuk_sahni
Community Manager

21-03-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.