# remove_comment_lines_from_haml_file.rb
require 'fileutils'
open('file.html.haml', 'r') do |f|
open('file.html.haml.tmp', 'w') do |f2|
f.each_line do |line|
f2.write(line) unless line =~ /^\s+\/.*$/ # regex for comments in haml template
end
end
end
FileUtils.mv 'file.haml.html.tmp', 'file.html.haml'
puts 'success'
Last active
December 7, 2016 14:50
-
-
Save Lumbe/f57c97c496570a69884b5e95b5f2b783 to your computer and use it in GitHub Desktop.
Remove lines from file on regex match
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment