Convert Haml to HTML without evaluating inline Ruby script
I need to convert Haml scripts to their equivalent HTML scripts. As I'm doing this o开发者_JAVA百科utside and without running the main rails project, the Ruby scripts present in the Haml files are throwing exceptions (which is obvious). Now, I won't mind if the Ruby script is present in the output HTML (in that case it'll look like an erb, that's fine for me). I'm concerned with some html tags only.
It seems like if I can override Haml::Engine#render(scope = Object.new, locals = {}, &block)
method then it could help. But not getting it fully.
Any idea?
Update
Converting only -
foo and =
foo blocks into Erb <% foo %>
and <%= foo %>
(respectively) won't work completely, because interpolation will be there, like:
%div{:class => "#{cycle("cssClass1", "cssClass2")} anotherCssClass"}
The acceptable output for my case can be:
<div class=<%= "#{cycle("cssClass1", "cssClass2")} anotherCssClass" %> ></div>
Other than those interpolations this works well for -
and =
.
Have you looked into the HAML to ERB converter gem?
精彩评论