简体   繁体   English

对于Play Framework 1.x,日本的Rythm模板引擎优势?

[英]Advantages Rythm Template Engine over Japid for Play Framework 1.x?

Rythm is a template engine for Play ! Rythm是Play的模板引擎! framework views. 框架视图。

It is type safe and provides an alternative to default groovy templates. 它是类型安全的,并提供默认groovy模板的替代方案。

Japid is also a similar template engine for Play ! Japid也是Play的类似模板引擎! Both Rythm and Japid are solving similar problems. Rythm和Japid都在解决类似的问题。

Rythm 节奏

http://www.playframework.org/modules/rythm http://www.playframework.org/modules/rythm

http://www.rythmengine.com/ http://www.rythmengine.com/

Japid Japid

http://www.playframework.org/modules/japid http://www.playframework.org/modules/japid

What are the advantages of Rythm over Japid ? Rythm比Japid有什么优势?

Rythm syntax is close to Play2 template syntax so the migration path will be easier. Rythm语法接近Play2模板语法,因此迁移路径将更容易。

Razor syntax on which is based Ryhtm was defined for C# templates and is clear and consistant. 基于Ryhtm的Razor语法是为C#模板定义的,并且清晰且一致。

In the other hand, Japid is older than Rythm and so can have more features and less bugs 另一方面,Japid比Rythm更老,因此可以拥有更多的功能和更少的错误

The biggest advantage of Japid over Rythm is the former has an Eclipse plugin while the latter has no tool support at the moment. Japid相对于Rythm的最大优势是前者有一个Eclipse插件,而后者目前没有工具支持。

Rythm wins at providing better Play-1.x integration. Rythm赢得了更好的Play-1.x集成。 See Integration Guide and Migration Guide 请参阅集成指南迁移指南

Another thing worth mentioned here is Rythm by default escape expression output like Groovy engine while Japid require you to explicitly escape it as ${escape(expr)} . 这里值得一提的另一件事是Rythm 默认转义表达式输出像Groovy引擎,而Japid要求你明确地将它作为${escape(expr)} That says Rythm tends to be safer to use while Japid votes more on performance. 这表明Rythm使用起来更安全,而Japid则更多地选择性能。

There should be no other big differences in terms of feature set of the both from my understanding. 根据我的理解,两者在功能集方面应该没有其他重大差异。 - Green, Author of Rythm - 格林,Rythm的作者

Updates 更新

Rythm has just released a feature called String Interpolation Mode (SIM), which allows you to omit argument declaration for simple cases, make it a good replacement for String.format in most cases: Rythm刚刚发布了一个名为String Interpolation Mode (SIM)的功能,它允许你省略简单情况的参数声明,在大多数情况下使它成为String.format一个很好的替代品:

String result = Rythm.render("Hello @who!", "world");

Note SIM beats String.format in 2 ways: 注意SIM以两种方式击败String.format

  1. Performance. 性能。 Rythm.render is 2 to 3 times faster than String.formant Rythm.renderString.formant快2到3倍
  2. Clear. 明确。 "Hello @who" is way clearer than "Hello %s". “Hello @who”比“Hello%s”更清晰。
  3. You can pass parameter to String.format() by position only, while Rythm.render supports both passing by position and by name 您可以仅按位置将参数传递给String.format() ,而Rythm.render支持按位置和按名称传递

I've implemented static-mustache library to provide a type-safe template engine based on mustache syntax. 我已经实现了静态胡子库,以提供基于胡子语法的类型安全模板引擎。

It checks both syntax errors and type-errors (like missing property) at compile-time like Rythm or Japid. 它在编译时检查语法错误和类型错误(如缺失属性),如Rythm或Japid。

It requires almost zero build configuration (in contrast to both Rytm and Japod which require custom plugins) as it's a standard annotation processor. 它需要几乎零构建配置(与需要自定义插件的Rytm和Japod相比),因为它是标准的注释处理器。

In static-mustache all type-information is extracted from a normal Java-class used for rendering. 在static-mustache中,所有类型信息都是从用于呈现的普通Java类中提取的。 A templating language remains pure "logicless" mustache. 模板语言仍然是纯粹的“无逻辑”胡子。 So templates can be shared between server-side and client-side renderers. 因此,可以在服务器端和客户端呈现器之间共享模板。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM