How can I convert html.slim to html.erb?

时光毁灭记忆、已成空白 提交于 2019-12-18 05:54:01

问题


I have many html.slim files that I would like to convert into html.erb files since I am not familiar with the slim syntax. Is there a converter for slim to erb?

I found a converter for html to slim that has the functionality I am looking for but it does not do slim to erb. http://html2slim.herokuapp.com/


回答1:


Use Slim::ERBConverter from slim itself , there is also a command-line tool slimrb, see http://rdoc.info/gems/slim/frames for more documentation.




回答2:


try the slimrb utility...

slimrb --erb html.slim



回答3:


They are both templating engines and they have different functionality.

I doubt there will ever be any kind of such a converter, because it is very complex task that requires "understanding in higher level" of the context, "understanding" why something is made in one template and recreating the same thing in another template engine. There is a reason why programmers will not likely be replaced anytime soon by AI - because it is hard to write a code that "understands in higher level" another code.

I do not see more than a few cases one should need such tool. Such tool would need to support both language functions, but they are not fully compatible (there are stuff, that exists in one, and is not available in another, and visa-versa).

To answer your original question, how you can convert slim to erb, my answer is, that you need to learn both languages and do it manually.

My suggestion is that you learn the one you are planning to use and stick with it (My suggestion would be ERB). If you are newbie, don't jump on different engines, stick with one, learn it to the bone and then, after years of experience, try doing the same or doing better with other engines.



来源:https://stackoverflow.com/questions/23277482/how-can-i-convert-html-slim-to-html-erb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!