Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2677 from guilleiguaran/refactor-sprockets-helpers

Refactoring javascript_include_tag and stylesheet_link_tag Sprockets helpers
  • Loading branch information...
commit e7634c2fdd7d1f4f177e593d0783e4d94149cba1 2 parents 09e2109 + 23b5c55
@spastorino spastorino authored
Showing with 6 additions and 19 deletions.
  1. +6 −19 actionpack/lib/sprockets/helpers/rails_helper.rb
View
25 actionpack/lib/sprockets/helpers/rails_helper.rb
@@ -26,15 +26,10 @@ def javascript_include_tag(*sources)
sources.collect do |source|
if debug && asset = asset_paths.asset_for(source, 'js')
asset.to_a.map { |dep|
- javascript_include_tag(dep, :debug => false, :body => true)
- }.join("\n").html_safe
+ javascript_include_tag(dep, options.stringify_keys.merge!({ :debug => false, :body => true }))
+ }
else
- tag_options = {
- 'type' => "text/javascript",
- 'src' => asset_path(source, 'js', body)
- }.merge(options.stringify_keys)
-
- content_tag 'script', "", tag_options
+ super(source.to_s, { 'src' => asset_path(source, 'js', body) }.merge!(options.stringify_keys))
end
end.join("\n").html_safe
end
@@ -43,22 +38,14 @@ def stylesheet_link_tag(*sources)
options = sources.extract_options!
debug = options.key?(:debug) ? options.delete(:debug) : debug_assets?
body = options.key?(:body) ? options.delete(:body) : false
- media = options.key?(:media) ? options.delete(:media) : "screen"
sources.collect do |source|
if debug && asset = asset_paths.asset_for(source, 'css')
asset.to_a.map { |dep|
- stylesheet_link_tag(dep, :media => media, :debug => false, :body => true)
- }.join("\n").html_safe
+ stylesheet_link_tag(dep, options.stringify_keys.merge!({ :debug => false, :body => true }))
+ }
else
- tag_options = {
- 'rel' => "stylesheet",
- 'type' => "text/css",
- 'media' => media,
- 'href' => asset_path(source, 'css', body, :request)
- }.merge(options.stringify_keys)
-
- tag 'link', tag_options
+ super(source.to_s, { 'href' => asset_path(source, 'css', body, :request) }.merge!(options.stringify_keys))
end
end.join("\n").html_safe
end
Please sign in to comment.
Something went wrong with that request. Please try again.