Skip to content

Instantly share code, notes, and snippets.

@jteneycke
Forked from kamali/gist:550231
Created February 9, 2014 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jteneycke/8899087 to your computer and use it in GitHub Desktop.
Save jteneycke/8899087 to your computer and use it in GitHub Desktop.
## based on the example at:
## http://gist.github.com/17371
##
## put me in lib/un_haml.rb (in the haml-based project)
##
## call me on the command line thus:
## $ script/runner UnHaml app/views/layouts/application.html.haml
## $ script/runner UnHaml */*/*/*.haml
##
class UnHaml < Haml::Engine
def push_script(text, preserve_script = false, 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
i = 0;
while (i < ARGV.length)
template = File.read(ARGV[i])
puts "<<<=========== IN #{ARGV[i]} =============="
#puts template
unhaml = UnHaml.new(template)
outfile = ARGV[i].sub(/.haml$/, '') + '.erb'
puts "============== OUT #{outfile} ===========>>>"
#puts unhaml.render
File.open(outfile, 'w') {|f| f.write(unhaml.render) }
i += 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment