Skip to content

Instantly share code, notes, and snippets.

@jberkel
Created February 19, 2010 13:15
Show Gist options
  • Select an option

  • Save jberkel/308686 to your computer and use it in GitHub Desktop.

Select an option

Save jberkel/308686 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
#
(ARGV.empty? ? Dir['**/*.haml'] : ARGV).each do |f|
lines = IO.readlines(f)
new_lines = []
lines.each_with_index do |l, i|
if l.match(/^\s*=\s*/) && lines[i-1] !~ /^\s*[\/%.=#-]/ && lines[i-1] && lines[i-1].strip.size > 0 && l !~ /\s*=\s*render/
new_lines << l.sub('=', '~')
else
new_lines << l
end
end
File.open(f, "w") { |f| f << new_lines.join }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment