lib/sprockets/helpers.rb in sprockets-helpers-1.0.1 vs lib/sprockets/helpers.rb in sprockets-helpers-1.1.0
- old
+ new
@@ -145,11 +145,11 @@
raise ::ArgumentError, 'block missing' unless block
options = { :expand => Helpers.debug || Helpers.expand, :debug => Helpers.debug }.merge(options)
path = asset_path(source, options)
output = if options[:expand] && path.respond_to?(:map)
- path.map(&block).join("\n")
+ "\n<!-- Expanded from #{source} -->\n" + path.map(&block).join("\n")
else
yield path
end
output = output.html_safe if output.respond_to?(:html_safe)
@@ -162,12 +162,14 @@
%Q(<script src="#{path}"></script>)
end
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(<link rel="stylesheet" href="#{path}">)
+ %Q(<link rel="stylesheet" href="#{path}"#{media_attr}>)
end
end
# Computes the path to a audio asset either in the Sprockets environment
# or the public directory. External URIs are untouched.