2009-09-28 22:43:08 -04:00
|
|
|
begin
|
|
|
|
require 'sprockets'
|
|
|
|
require 'middleman/features/sprockets+ruby19' # Sprockets ruby 1.9 duckpunch
|
|
|
|
rescue LoadError
|
|
|
|
puts "Sprockets not available. Install it with: gem install sprockets"
|
|
|
|
end
|
|
|
|
|
|
|
|
module Middleman
|
|
|
|
module Sprockets
|
2009-09-29 13:10:47 -04:00
|
|
|
def self.included(base)
|
|
|
|
base.supported_formats << "js"
|
|
|
|
end
|
|
|
|
|
2009-09-28 22:43:08 -04:00
|
|
|
def render_path(path)
|
|
|
|
source = File.join(options.public, path)
|
|
|
|
if File.extname(path) == '.js' && File.exists?(source)
|
|
|
|
secretary = ::Sprockets::Secretary.new( :asset_root => options.public,
|
|
|
|
:source_files => [source] )
|
2009-10-15 14:07:08 -04:00
|
|
|
# may need to rejigger since sprockets will only read views/ now
|
2009-09-28 22:43:08 -04:00
|
|
|
secretary.concatenation.to_s
|
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2009-09-29 13:10:47 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
class Middleman::Base
|
|
|
|
include Middleman::Sprockets
|
2009-09-28 22:43:08 -04:00
|
|
|
end
|