#StackBounty: #javascript #handlebars.js Upgrading to precompiled Handlebars 4.7.6 templates fails to render

Bounty: 50

Since I upgraded to Handlebars 4.7.6 I’m getting an error trying to render my precompiled templates. I upgraded the js runtime to the same version but my template fails to load.

This is the code trying to render the template:

var template = Handlebars.templates.index;
var rendered = template(data);

and the error: TypeError: template is not a function

When I inspect the differences in the code of a 4.7.3 compiled template I see that the older versions handles the object creation differently than the newer template. On the beginning of the file the templates are different:

ver: 4.7.3

!function(){var l=Handlebars.template;(Handlebars.templates=Handlebars.templates||{}).index=l({1:function(l,n,e,a,t){...

ver: 4.7.6

!function(){var l=Handlebars.template;(Handlebars.templates=Handlebars.templates||{})["handlebars.index"]=l({1:function(l,n,e,a,t){...

If I manually change ["handlebars.index"] to index then my template renders correctly. But I don’t want manually to change the code of the template every time I compile a new one.

Is there something I can change on my code for making it work?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.