Looking for a template engine which can be used in Java and JavaScript

As the title says, I’m currently looking for a template engine that works with Java and Javascript. The idea is that my ajax json objects can use the same template files to render stuff client-side like Java is doing it server-side.

I know there is google-closure-template but it is working with guice 2.0 and my current project runs under guice 3.0 and both together just create wierd errors and I tried using them but failed for about 2 weeks now…

  • What does the @private annotation actually do in Google Closure JavaScript code?
  • How to use Google's Closure to compile JavaScript
  • Jquery vs Google Closure va GWT Pros & cons for large web application development
  • Closure event delegation - event listener on DOM parent that covers children/descendants of a given class
  • prevent event propagation using Google Closure Library
  • Understanding “this” context with goog.bind and goog.net.Xhrio.send
  • So is there anything apart from google-closure?

  • How do I get the Closure Compiler to stop complaining about union types when calling a function?
  • WARNING - dangerous use of the global this object
  • Why is it that “Member must not have @private JsDoc”?
  • how do I break up a regular expression in JavaScript
  • How can I load my own js module with goog.provide and goog.require?
  • Google Closure - Form data to json object
  • 3 Solutions collect form web for “Looking for a template engine which can be used in Java and JavaScript”

    You can take a look at Mustache.

    Also Histone seems to be for both

    BTW: the same topic is here

    I realize this is an old question, but have you considered firing up a javax.script.ScriptEngine and running the same JS templating system in Java as well? That way you can choose the template system you actually want rather than compromising based on what languages implement it. I doubt that embedded JS in Java (Rhino/Nashorn) will perform as a well as a native Java implementation, but depending on your application that might not matter.