Created
September 21, 2012 15:49
-
-
Save RickCarlino/3762274 to your computer and use it in GitHub Desktop.
inline coffeescript in HAML with :coffee and on-the-fly compilation
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
# inline coffeescript for haml with on-the-fly compilation | |
# run this script in the directory of your project | |
require 'fssm' | |
#required for using inline :coffee tag with HAML- | |
require 'coffee-filter' | |
directory = File.dirname(__FILE__) | |
FSSM.monitor(directory, '**/*') do | |
update do |base, relative| | |
if relative.match(/.coffee\z/) | |
input = "#{base}/#{relative}" | |
output = "#{base}/#{relative.gsub!('.coffee', '.js')}" | |
command = "coffee -c #{input}" | |
%x{#{command}} | |
puts "[COFFEE] Regenerated #{input} to #{output}" | |
elsif relative.match(/.haml\z/) | |
input = "#{base}/#{relative}" | |
output = "#{base}/#{relative.gsub!('.haml', '')}" | |
command = "haml -r coffee-filter #{input} #{output}" | |
%x{#{command}} | |
puts "[HAML] Regenerated #{input} to #{output}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment