Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
## 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
You can’t perform that action at this time.