Java 速度与 FreeMarker
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1459426/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Velocity vs. FreeMarker
提问by flybywire
Velocity or FreeMarker?
Velocity 还是 FreeMarker?
They look pretty much the same, even the syntax?
它们看起来几乎相同,甚至语法?
What to use? Or when to use what?
用什么?或者什么时候用什么?
采纳答案by skaffman
Velocity isn't really under active development any more. Freemarker is.
Velocity 不再真正处于积极开发之中。弗里马克是。
Freemarker is also a lot more flexible, in my experience.
根据我的经验,Freemarker 也更加灵活。
回答by leonm
They try to differentiate themselves from time to time (example).
他们不时尝试让自己与众不同(例如)。
I've worked extensively with both and from my perspective they're very similar. There are just so many features that you can build into a templating language, the rest is just fluff.
我已经与两者进行了广泛的合作,从我的角度来看,它们非常相似。有很多功能可以构建到模板语言中,其余的只是绒毛。
回答by John Doe
Use Freemarker if you can :
如果可以,请使用 Freemarker:
- Still in active development like @skaffman said
- Good documentation, better than Velocity IMHO
- Provided as alternative templating language in many web frameworks
- Less dependencies than Velocity
- More complete than the raw Velocity without extensions.
- Also see the link provided by @leonm
- 仍在积极开发中,就像@skaffman 所说
- 良好的文档,比 Velocity 恕我直言更好
- 在许多 Web 框架中作为替代模板语言提供
- 比 Velocity 依赖更少
- 比没有扩展的原始 Velocity 更完整。
- 另请参阅@leonm 提供的链接
回答by jrb
The goals for the projects are different.
项目的目标不同。
Velocity's goal is to keep templates as simple as possible, to help maintain a segregation between logic and presentation, so you don't slide down the slippery slope of sticking code in templates. Sometimes this is the right thing. Of course, sometimes being able to wire complicated logic directly into templates is the right thing.
Velocity 的目标是使模板尽可能简单,以帮助保持逻辑和表示之间的隔离,这样您就不会滑下将代码粘贴到模板中的滑坡。有时这是正确的事情。当然,有时能够将复杂的逻辑直接连接到模板中是正确的。
Velocity doesn't get frequently rev'd, but that doesn't mean it's not under active development. The user community is large, the code is fast and stable, the syntax is basically fixed. Over the last several years Freemarker has undergone churn on the template syntax and api side. Sometimes it's nice to leave well enough alone. Again, depends on what you're looking for.
Velocity 不会经常更新,但这并不意味着它没有处于积极开发阶段。用户群体大,代码快速稳定,语法基本固定。在过去的几年里,Freemarker 在模板语法和 API 方面经历了一些变化。有时,一个人待着很好。再次,取决于你在寻找什么。
Freemarker's documentation is much more extensive- and it's a much more complicated piece of software.
Freemarker 的文档要广泛得多,而且它是一个复杂得多的软件。
Many of the use cases for Freemarker boil down to wanting a complex templating workflow and not wanting a compilation step. In recent years, rather than struggle through this with Java I've just been using Python or Ruby instead.
Freemarker 的许多用例归结为需要复杂的模板工作流程而不需要编译步骤。近年来,我没有用 Java 来解决这个问题,而是一直使用 Python 或 Ruby。
回答by A. Ionescu
There are two published books about Velocity:
有两本关于速度的出版书籍:
and other books that have chapters about it too. So, that much about FreeMarker having more or better docs :).
和其他有关于它的章节的书。所以,关于 FreeMarker 有更多或更好的文档就这么多了:)。