flowerbox-delivery/lib/flowerbox/delivery/tilt/template_that_saves.rb

33 lines
543 B
Ruby
Raw Normal View History

2012-02-08 17:41:18 +00:00
module Flowerbox::Delivery::Tilt::TemplateThatSaves
def prepare ; end
def handle_evaluate
case File.extname(file)
when '.js'
file
else
save
end
end
def save
FileUtils.mkdir_p File.dirname(temp_file)
File.open(temp_file, 'wb') { |fh| fh.print data }
temp_file
end
def temp_file
2012-03-08 15:14:45 +00:00
File.join(Dir.pwd, ".tmp/sprockets", file.gsub(%r{(\.#{extension})(.*)$}, '\1'))
end
def evaluate(scope, locals, &block)
handle_evaluate
end
def extension
self.class::EXTENSION
2012-02-08 17:41:18 +00:00
end
end