Erlang 模板引擎。 sgte、google-cTemplate 或 erlydtl
我打算在我的erlang项目中实现一个模板引擎,最重要的是性能。目前我有很多 Velocity Java 模板,我想将可用的模板迁移到 erlang。
我用谷歌搜索,发现了类似的东西;
- http://www.ivan.fomichev.name/2008 /05/erlang-template-engine-prototype.html
- erlydtl
- google-ctemplate
- sgte
纯erlang实现将是最好的,但是基于c(c++)的模板引擎,即google-ctemplate,性能更好,我会使用它与 erlang 链接在驱动程序中。
还没有这方面的经验,所以任何人的建议都会非常好。
谢谢
I am planning to implement a template engine to my erlang project, and the most important thing is the performance. Currently I have a lot of Velocity Java template, and I want to migrate templates available to erlang.
I googled it, and found things like;
- http://www.ivan.fomichev.name/2008/05/erlang-template-engine-prototype.html
- erlydtl
- google-ctemplate
- sgte
Pure erlang implementation would be the best, but c(c++) based template engine, i.e. google-ctemplate, performs better, I would use it with erlang linked in driver.
Have no experience on this matter yet, so anyone's suggestions would be super great.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我个人最喜欢的是erlydtl。它将模板编译为 erlang 模块,因此在调用“render”时不会消耗文件系统访问或解析时间。
我认为现在 rebar 有 erlydtl 支持,所以编译模板比以前少了很多麻烦。只需将它们命名为
*.dtl
,它们就会在您运行rebarcompile
时构建。它在速度方面也应该具有相当的竞争力,因为它是进程内的(跳过端口程序的 IPC 成本)、编译的(并且如果您愿意的话可以编译为本机代码)并生成非常高效的 iolist。
My personal favourite is erlydtl. It compiles the template to an erlang module, so there's no filesystem access or parsing time consumed when you call 'render'.
I think rebar has erlydtl support these days, so getting your templates compiled is a lot less hassle than it used to be. Just name them
*.dtl
and they'll get built when you runrebar compile
.It should also be fairly competitive speed wise as it's in-process (skip the IPC cost of a port program), compiled (and could be compiled to native code if you wanted to), and generates iolists which are pretty efficient.