lib/sinatra/classy_assets.rb in classy_assets-0.3.2 vs lib/sinatra/classy_assets.rb in classy_assets-0.4.0

- old
+ new

@@ -1,34 +1,28 @@ # encoding: utf-8 require 'rack/classy_assets' -require 'sinatra/sprockets-helpers' module Sinatra module ClassyAssets - def self.registered(app) - app.use Rack::ClassyAssets - app.register Sprockets::Helpers - app.configure do - ::Sprockets::Helpers.configure do |config| - classy_config = ::ClassyAssets::Configuration - manifest_file = ::File.join(config.public_path, - classy_config.asset_prefix, - 'manifset.json') - - config.asset_host = classy_config.asset_host - config.debug = classy_config.debug_mode - config.digest = classy_config.asset_digest - config.environment = classy_config.sprockets - config.public_path = classy_config.public_path - config.prefix = "/#{classy_config.asset_prefix}" - config.protocol = classy_config.asset_host_protocol - - if ::File.exists? manifest_file - config.manifest = ::Sprockets::Manifest.new(config.environment, manifest_file) - end + module Helpers + def stylesheet_tag(sources, options = {}) + options = { media: 'screen' }.merge(options) + ::ClassyAssets.asset_tag_from(sources, 'css') do |asset_url| + %Q{<link href="#{asset_url}" media="#{options[:media]}" rel="stylesheet">} end end + + def javascript_tag(sources) + ::ClassyAssets.asset_tag_from(sources, 'js') do |asset_url| + %Q{<script src="#{asset_url}"></script>} + end + end + end + + def self.registered(app) + app.use ::Rack::ClassyAssets + app.helpers Helpers end end register ClassyAssets end