Cross Java and Javascript Template Language?

五迷三道 提交于 2019-12-18 13:19:32

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/8871425/cross-java-and-javascript-template-language

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!