There seem to be a lot of template languages for both Java (e.g. JSP, JSTL, Freemarker, Velocity, ...) and for Javascript (e.g. Mustache, Ext's XTemplate, Jquery templates, ...) but is there one which have an implementation for both?
Ideally I'd like to be able to have an template which can be evaluated either on the server or on the client side without too much hassle switching over.
JavaScript templating refers to the client side data binding method implemented with the JavaScript language. This approach became popular thanks to JavaScript's increased use, its increase in client processing capabilities, and the trend to outsource computations to the client's web browser.
In 1999 Sun Microsystems released Java Server Pages (JSP), which is a template engine for Java web applications.
Spring MVC, Struts or Apache Wicket are examples of web frameworks, whereas JSP, Velocity or FreeMarker are examples of template engines.
EJS. Embedded JavaScript, or, EJS, is a templating language that lets you generate HTML with plain JavaScript in between. It is a very simple language and is a good choice for students if they ever need to choose a templating language.
Google Closure/Soy templates.
The Wikipedia Page for Web Templating Languages reveals another one: Casper.
Both these solutions don't use a common template file which is directly evaluated in JS or Java. The template must first be compiled into an intermediate JS before evaluation on the client. (For Closure, this is fairly easy to do with ant
and an included SoyToJsSrcCompiler.jar
command line tool. Not sure about with Casper.)
EDIT: Another possibility is Mustache, which does not require templates to be compiled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With