sprockets-helpers 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -147,7 +147,7 @@ module Sprockets
147
147
 
148
148
  path = asset_path(source, options)
149
149
  output = if options[:expand] && path.respond_to?(:map)
150
- path.map(&block).join("\n")
150
+ "\n<!-- Expanded from #{source} -->\n" + path.map(&block).join("\n")
151
151
  else
152
152
  yield path
153
153
  end
@@ -164,9 +164,11 @@ module Sprockets
164
164
  end
165
165
 
166
166
  def stylesheet_tag(source, options = {})
167
+ media = options.delete(:media)
168
+ media_attr = media.nil? ? nil : " media=\"#{media}\""
167
169
  options = Helpers.default_path_options[:stylesheet_path].merge(options)
168
170
  asset_tag(source, options) do |path|
169
- %Q(<link rel="stylesheet" href="#{path}">)
171
+ %Q(<link rel="stylesheet" href="#{path}"#{media_attr}>)
170
172
  end
171
173
  end
172
174
 
@@ -1,5 +1,5 @@
1
1
  module Sprockets
2
2
  module Helpers
3
- VERSION = '1.0.1'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
@@ -522,6 +522,10 @@ describe Sprockets::Helpers do
522
522
  expect(context.stylesheet_tag('main')).to eq('<link rel="stylesheet" href="/stylesheets/main.css">')
523
523
  end
524
524
 
525
+ it 'uses media attribute when provided' do
526
+ expect(context.stylesheet_tag('main', :media => "print")).to eq('<link rel="stylesheet" href="/stylesheets/main.css" media="print">')
527
+ end
528
+
525
529
  describe 'when expanding' do
526
530
  it 'generates stylesheet tag for each stylesheet asset' do
527
531
  within_construct do |construct|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-20 00:00:00.000000000 Z
12
+ date: 2013-11-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sprockets
@@ -156,7 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
156
156
  version: '0'
157
157
  segments:
158
158
  - 0
159
- hash: 1829303642401758750
159
+ hash: -393383161037819423
160
160
  required_rubygems_version: !ruby/object:Gem::Requirement
161
161
  none: false
162
162
  requirements:
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  version: '0'
166
166
  segments:
167
167
  - 0
168
- hash: 1829303642401758750
168
+ hash: -393383161037819423
169
169
  requirements: []
170
170
  rubyforge_project: sprockets-helpers
171
171
  rubygems_version: 1.8.23