Created
April 14, 2011 15:32
-
-
Save utkarshkukreti/919724 to your computer and use it in GitHub Desktop.
Watch a directory for changes on *.haml files, and automatically compile them to *.html
This file contains 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
# Save as Rakefile, and run `rake watch` | |
def recompile(base, relative) | |
haml = File.join(base, relative) | |
html = File.join(base, relative.gsub(/\.haml$/, '.html')) | |
print ">>> Change detected to #{relative} >> " | |
system "haml", haml, html | |
puts "Compiled <<<" | |
end | |
desc "Watch HAML files for changes" | |
task :watch do | |
require 'fssm' | |
puts ">>> Watching for changes <<<" | |
FSSM.monitor(Dir.pwd, '**/*.haml') do | |
update &method(:recompile) | |
create &method(:recompile) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment