跨 Java 和 Javascript 模板语言?

发布于 2024-12-27 06:27:11 字数 187 浏览 2 评论 0原文

似乎有很多 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧话新听 2025-01-03 06:27:11

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 included SoyToJsSrcCompiler.jar command line tool. Not sure about with Casper.)

EDIT: Another possibility is Mustache, which does not require templates to be compiled.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文