Created
April 1, 2012 09:31
-
-
Save znake/2274099 to your computer and use it in GitHub Desktop.
Watch Rakefile for HAML
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 this file as rakefile.rb in your folder | |
# within your .haml files. | |
# Start watching with | |
# $ rake | |
include Rake::DSL | |
require 'rake/clean' | |
task :default => [:watch] | |
desc 'Watches all the .haml files in your directory and changes them to html' | |
task :watch do | |
puts "HAML is watchin you!" | |
require 'fssm' | |
FSSM.monitor do | |
path "#{File.dirname(__FILE__)}" do | |
glob '**/*.{haml}' | |
update {|base, relative| rebuild_haml(relative)} | |
delete {|base, relative| rebuild_haml(relative)} | |
create {|base, relative| rebuild_haml(relative)} | |
end | |
end | |
end | |
def rebuild_haml(relative) | |
puts "HAML changes found in: #{relative}! Invoking HAML --->" | |
html = relative.sub( "haml", "html") | |
sh "haml #{relative} #{html}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment