Ruby-on-rails 有没有好的 HAML -> ERB/HTML 转换器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/967262/
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
Is there a good HAML -> ERB/HTML converter?
提问by
I'm looking for a reliable way to convert a HAML template to an equivalent ERB/HTML template?
我正在寻找一种可靠的方法将 HAML 模板转换为等效的 ERB/HTML 模板?
Has anyone come across one?
有人遇到过吗?
回答by user2710230
I recommend you to use HAML2ERBservice. It's really cool and generates valid ERB/HTML code! The benefits are:
我建议您使用HAML2ERB服务。它真的很酷并且可以生成有效的 ERB/HTML 代码!好处是:
- HTTPS - if you need some security for your markup;
- API - you could write the plugin or something else for your IDE;
- Simple - just put your HAML code to the textbox and click "Convert";
- Project is active - the author is currently working on it.
- HTTPS - 如果您的标记需要一些安全性;
- API - 你可以为你的 IDE 编写插件或其他东西;
- 简单 - 只需将您的 HAML 代码放入文本框并单击“转换”;
- 项目处于活动状态 - 作者目前正在处理它。
Project was tested on big HAML views (over 800 lines of markup) from the real production app and it worked fine for me.
项目在来自真实生产应用程序的大型 HAML 视图(超过 800 行标记)上进行了测试,对我来说效果很好。
Good luck!
祝你好运!
回答by wharsojo
have you try W2tags, you can even test it live in: w2tags.heroku.com
您是否尝试过 W2tags,您甚至可以在以下位置进行测试:w2tags.heroku.com
回答by dan
I just wrote a HAML to ERB translator in Haskell. https://github.com/danchoi/herbalizer
我刚刚用 Haskell 写了一个 HAML 到 ERB 的翻译器。https://github.com/danchoi/herbalizer
If you're still trying to find a tool for this problem, let me know if it works well enough or not.
如果您仍在尝试找到解决此问题的工具,请告诉我它是否足够好用。
回答by austinfromboston
Apparently there's some challenging issues with translating HAML to ERB, as HAML supports some niceties that don't easily translate back to ERB without parsing the Ruby code. A naive implementation using the HAML engine is here:
显然,将 HAML 转换为 ERB 存在一些具有挑战性的问题,因为 HAML 支持一些在不解析 Ruby 代码的情况下不容易转换回 ERB 的细节。使用 HAML 引擎的简单实现如下:
回答by Micha?l Witrant
There is our fork of haml2erbwhich does not support all the HAML syntax, but it's good enough for us to write Rhomobile views in HAML.
还有我们的haml2erb叉不支持所有的HAML语法,但它不够好,我们写Rhomobile的意见HAML。

