aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorGuillermo Iguaran <guilleiguaran@gmail.com>2011-06-05 00:58:37 -0500
committerGuillermo Iguaran <guilleiguaran@gmail.com>2011-06-05 01:01:35 -0500
commitdb8eeaff06009deac2d34337942a8b8414dfd7ba (patch)
treeb39a78b4d7c3d586b3a01ca0b3496a30d04c46b1 /actionpack/lib
parent75e56101d4412a9a669d7bbe4b85d6ee230ff9fa (diff)
downloadrails-db8eeaff06009deac2d34337942a8b8414dfd7ba.tar.gz
rails-db8eeaff06009deac2d34337942a8b8414dfd7ba.tar.bz2
rails-db8eeaff06009deac2d34337942a8b8414dfd7ba.zip
Allow multiple sources in Sprockets helpers
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/sprockets/helpers/rails_helper.rb62
1 files changed, 34 insertions, 28 deletions
diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb
index a99dcad81d..dcf4b9279e 100644
--- a/actionpack/lib/sprockets/helpers/rails_helper.rb
+++ b/actionpack/lib/sprockets/helpers/rails_helper.rb
@@ -15,42 +15,48 @@ module Sprockets
end
end
- def javascript_include_tag(source, options = {})
+ def javascript_include_tag(*sources)
+ options = sources.extract_options!
debug = options.key?(:debug) ? options.delete(:debug) : debug_assets?
body = options.key?(:body) ? options.delete(:body) : false
- 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
- else
- options = {
- 'type' => "text/javascript",
- 'src' => asset_path(source, 'js', body)
- }.merge(options.stringify_keys)
-
- content_tag 'script', "", options
- end
+ 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
+ else
+ tag_options = {
+ 'type' => "text/javascript",
+ 'src' => asset_path(source, 'js', body)
+ }.merge(options.stringify_keys)
+
+ content_tag 'script', "", tag_options
+ end
+ end.join("\n").html_safe
end
- def stylesheet_link_tag(source, options = {})
+ 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
- if debug && asset = asset_paths.asset_for(source, 'css')
- asset.to_a.map { |dep|
- stylesheet_link_tag(dep, :debug => false, :body => true)
- }.join("\n").html_safe
- else
- options = {
- 'rel' => "stylesheet",
- 'type' => "text/css",
- 'media' => "screen",
- 'href' => asset_path(source, 'css', body)
- }.merge(options.stringify_keys)
-
- tag 'link', options
- end
+ sources.collect do |source|
+ if debug && asset = asset_paths.asset_for(source, 'css')
+ asset.to_a.map { |dep|
+ stylesheet_link_tag(dep, :debug => false, :body => true)
+ }.join("\n").html_safe
+ else
+ tag_options = {
+ 'rel' => "stylesheet",
+ 'type' => "text/css",
+ 'media' => "screen",
+ 'href' => asset_path(source, 'css', body)
+ }.merge(options.stringify_keys)
+
+ tag 'link', tag_options
+ end
+ end.join("\n").html_safe
end
private