diff --git a/lib/sprockets/helpers.rb b/lib/sprockets/helpers.rb index 2296a2b..793ca75 100755 --- a/lib/sprockets/helpers.rb +++ b/lib/sprockets/helpers.rb @@ -160,9 +160,11 @@ def javascript_tag(source, options = {}) end def stylesheet_tag(source, options = {}) + media = options.delete(:media) + media_attr = media.nil? ? nil : " media=\"#{media}\"" options = Helpers.default_path_options[:stylesheet_path].merge(options) asset_tag(source, options) do |path| - %Q() + %Q() end end diff --git a/spec/sprockets-helpers_spec.rb b/spec/sprockets-helpers_spec.rb index c8a4cd7..50643c3 100755 --- a/spec/sprockets-helpers_spec.rb +++ b/spec/sprockets-helpers_spec.rb @@ -520,6 +520,10 @@ expect(context.stylesheet_tag('main')).to eq('') end + it 'uses media attribute when provided' do + expect(context.stylesheet_tag('main', :media => "print")).to eq('') + end + describe 'when expanding' do it 'generates stylesheet tag for each stylesheet asset' do within_construct do |construct|