Skip to content

Instantly share code, notes, and snippets.

@blakesmith
Created September 6, 2010 01:18
Show Gist options
  • Save blakesmith/566505 to your computer and use it in GitHub Desktop.
Save blakesmith/566505 to your computer and use it in GitHub Desktop.
# Script to watch a directory for any changes to a haml file
# and compile it.
#
# USAGE: ruby haml_watch.rb <directory_to_watch>
#
require 'rubygems'
require 'fssm'
directory = File.join(File.dirname(__FILE__), ARGV.first)
FSSM.monitor(directory, '**/*.haml') do
update do |base, relative|
input = "#{base}/#{relative}"
output = "#{base}/#{relative.gsub!('.haml', '.html')}"
command = "haml #{input} #{output}"
%x{#{command}}
puts "Regenerated #{input} to #{output}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment