跨 Java 和 Javascript 模板语言?
似乎有很多 Java 模板语言(例如 JSP、JSTL、Freemarker、Velocity 等)和 Javascript 模板语言(例如 Mustache、Ext 的 XTemplate、Jquery 模板等),但是是否有一种模板语言具有两者的实施?
理想情况下,我希望能够有一个可以在服务器或客户端上进行评估的模板,而无需太多的切换麻烦。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Google Closure/Soy 模板。
Web 模板语言维基百科页面揭示了另一种:Casper。
这两种解决方案都不使用直接在 JS 或 Java 中计算的通用模板文件。在客户端评估之前,模板必须首先编译成中间 JS。 (对于 Closure,使用
ant
和包含的SoyToJsSrcCompiler.jar
命令行工具可以很容易地做到这一点。对于 Casper 不确定。)编辑:另一种可能性是 Mustache,不需要编译模板。
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 includedSoyToJsSrcCompiler.jar
command line tool. Not sure about with Casper.)EDIT: Another possibility is Mustache, which does not require templates to be compiled.