-
-
Save RickCarlino/3762267 to your computer and use it in GitHub Desktop.
Watch and compile all haml files on a directory, like sass --watch
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
#!/usr/bin/env ruby | |
# Script to watch a directory for any changes to a haml file | |
# and compile it. | |
# | |
# USAGE: ruby haml_watch.rb <directory_to_watch> [output_directory] | |
# | |
# Blake Smith / http://blakesmith.github.com/2010/09/05/haml-directory-watcher.html | |
# | |
require 'rubygems' | |
require 'fssm' | |
from_path = ARGV[0] || "src" | |
to_path = ARGV[1] || "bin" | |
dir = File.join(File.dirname(__FILE__), from_path) | |
FSSM.monitor(dir, '**/*.haml') do | |
update do |base, relative| | |
input = File.join(base, relative) | |
output = File.join(File.dirname(base), to_path, relative.gsub!('.haml', '.html')) | |
command = "haml #{input} #{output} -f xhtml -t ugly -q --no-escape-attrs" | |
%x{#{command}} | |
puts <<-eos | |
HTML gerado #{Time.now.strftime("%Y/%m/%d %H:%M")}: | |
- from: #{input} | |
- to: #{output} | |
eos | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment