-
-
Save LeoNogueira/925237 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment