Skip to content

Instantly share code, notes, and snippets.

@utkarshkukreti
Created April 14, 2011 15:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save utkarshkukreti/919724 to your computer and use it in GitHub Desktop.
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
# 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