Handlebars.Java precompiled templates

682 views
Skip to first unread message

mehmood Khan

unread,
Feb 20, 2014, 2:51:45 PM2/20/14
to handleb...@googlegroups.com
Hi 

 We have been trying to manage the templates precompiled on the java side , by doing it at startup and cache this templates for future use.

 So we maintained a HashMap<String, Template> , String being the name of the template.
 So we add this data in context object and access it in a handlebar.js helper method like mapObject.get(template).apply(modContext)

 It works , but we have this weird WARN 

  RHINO USAGE WARNING: Missed Context.javaToJS() conversion
 
But the page loads fine, I digged into the code and rhino seems to have this warning from ScriptRuntime.java class. So I am figuring out, since the Map is a default value resolver for the handlerbars.java, why this weird is throwing up?

 Also the approach is the right one? Is there a better way to precompile the templates and use it .


Thanks.

edgar

unread,
Feb 20, 2014, 8:00:42 PM2/20/14
to handleb...@googlegroups.com
no idea what does mean, it's something from Rhino obviously.

Handlebars.java already had a cache system, so no need to do it manually. Check here: https://github.com/jknack/handlebars.java#the-cache-system

I strongly recommend the Guava implementation.

mehmood Khan

unread,
Feb 21, 2014, 11:42:09 AM2/21/14
to handleb...@googlegroups.com
Thanks Edgar for your suggestions. I will try it out.

mehmood Khan

unread,
May 22, 2014, 6:12:35 PM5/22/14
to handleb...@googlegroups.com
Edgar,

 This helped a lot , Implemented Gauva Cache and Looks awesome. Earlier I was trying to send the whole template object to a helper JS file for compiling template in further includes. But now moved that logic to Java to make use of Cache and the error also got resolved.
Reply all
Reply to author
Forward
0 new messages