Skip to content

Instantly share code, notes, and snippets.

@aviddiviner
Created November 22, 2012 23:16
Show Gist options
  • Select an option

  • Save aviddiviner/4133283 to your computer and use it in GitHub Desktop.

Select an option

Save aviddiviner/4133283 to your computer and use it in GitHub Desktop.
HAML to ERB Converter
#!/usr/bin/env ruby
# Usage: ./haml-to-erb.rb myfile.haml > myfile.erb
# Usage: cat myfile.haml | ./haml-to-erb.rb > myfile.erb
require 'haml'
class ErbEngine < Haml::Engine
def push_script(text, preserve_script, in_tag = false, preserve_tag = false,
escape_html = false, nuke_inner_whitespace = false)
push_text "<%= #{text.strip} %>"
end
def push_silent(text, can_suppress = false)
push_text "<% #{text.strip} %>"
end
end
e = ErbEngine.new(ARGF.read)
puts e.render
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment