Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross Java and Javascript Template Language?

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.

like image 596
Mark Rhodes Avatar asked Jan 15 '12 16:01

Mark Rhodes


People also ask

Is JavaScript a templating language?

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.

Is JSP a template language?

In 1999 Sun Microsystems released Java Server Pages (JSP), which is a template engine for Java web applications.

Is JSP a template engine?

Spring MVC, Struts or Apache Wicket are examples of web frameworks, whereas JSP, Velocity or FreeMarker are examples of template engines.

What language is used to write a template?

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.


1 Answers

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.

like image 136
Francis Avila Avatar answered Sep 20 '22 01:09

Francis Avila