Google App Engine 的模板引擎
您能为 GAE 推荐一个模板引擎吗? 我喜欢 Wicket,但它带有很多服务器端状态,这与GAE 方法。
GAE 是否支持 FreeMarker?
编辑
我对模板引擎的主要要求是:
- 易于开发(逻辑和设计分离)
- 直观的语法,因为用户可以自定义一些模板
- 快速、轻量级
Can you recommend a template engine for GAE?
I like Wicket, but it carries a lot of server-side state, which is something that is not very compatible with the GAE approach.
Is FreeMarker supported on GAE?
EDIT
My primary requirements for the template engine are:
- Ease of development (separation of logic and design)
- Intuitive syntax, since users may customize some templates
- Fast, lightweight
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看 Play 框架。它支持GAE并且完全支持GAE。 playframework.org/documentation/1.1/guide5#aHowdowemanagethestatea" rel="noreferrer">无状态服务器端。
Check out the Play framework. It has support for GAE and is completely stateless server-side.
我在 GAE 上使用 FreeMarker 非常成功。我让它处理所有 html 文件,并使用欢迎文件目录处理工作正常。有关详细信息,请参阅这个其他 stackoverflow 问题< /a>.我那里有我的 web.xml 文件和其他详细信息。
I am using FreeMarker on GAE quite successfully. I have it handling all of the html files with welcome-file directory handling working fine. For more information, see this other stackoverflow question. I have my web.xml file and other details there.
Rythm 是一个强类型 Java 模板引擎,使用类似 Razor 的语法,具有高性能(比 Velocity 和 FM 快 2 到 3 倍) )。它提供了一种非常轻量级的方法来进行字符串插值:
这种简单性使得 Rythm 在许多情况下成为
String.format()
的良好替代品。请注意,Rythm.render
比String.format
快 2 倍对于综合模板,您可以使用相同的接口来传递文件名:
Rythm 具有非常丰富的功能集包括java流程控制(if-else、for循环、集合迭代)、模板继承、外部和内部标签创建和调用、缓存、Java方法扩展、空间紧凑、html转义等。大多数功能在 http://play-rythm-demo.appspot.com/。 (是的,该演示是用 Play!Framework 加上 Rythm 模板引擎编写的,并且在 GAE 上运行!)
在 Rythm 引擎上创建了 Play!Framework 插件,您可以从那里找到有关如何使用 Rythm 的文档: http://www.playframework.org/modules/rythm
您可以从 https://github.com/greenlaw110/rythm/downloads
Rythm is a Strong typed Java template engine using Razor like syntax with high performance (2 to 3 times faster than Velocity and FM). It provides a very lightweight way to do String interpolation:
This simplicity makes Rythm a good replacement for
String.format()
in many cases. Please be noted thatRythm.render
is 2x faster thanString.format
For comprehensive template you can use the same interface to pass in the file name:
Rythm has very rich feature set including java flow control (if-else, for loop, collection iteration), template inheritance, external and internal tags creation and invocation, caching, Java method extension, space compact, html escape etc. Most of the features are demonstrated at http://play-rythm-demo.appspot.com/. (And Yes, the demo is written with Play!Framework plus Rythm template engine and it is running on GAE!)
There is Play!Framework plugin created on Rythm engine, you can find documentation on how to use Rythm from there: http://www.playframework.org/modules/rythm
You can download Rythm from https://github.com/greenlaw110/rythm/downloads