diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index 134eaab8bc549de1067dd5f18d419de512814622..251b8f8005f3b0b97805fa2dd947559a12e549d2 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/array/extract_options'
+require 'active_support/core_ext/hash/keys'
require 'action_view/helpers/asset_tag_helpers/javascript_tag_helpers'
require 'action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers'
require 'action_view/helpers/asset_tag_helpers/asset_paths'
@@ -407,12 +409,15 @@ def image_alt(src)
#
# video_tag("/trailers/hd.avi", :height => '32', :width => '32') # =>
#
+ # video_tag("trailer.ogg", "trailer.flv") # =>
+ #
# video_tag(["trailer.ogg", "trailer.flv"]) # =>
- #
+ #
# video_tag(["trailer.ogg", "trailer.flv"] :size => "160x120") # =>
- #
- def video_tag(sources, options = {})
- options.symbolize_keys!
+ #
+ def video_tag(*sources)
+ options = sources.extract_options!.symbolize_keys!
+ sources.flatten!
options[:poster] = path_to_image(options[:poster]) if options[:poster]
@@ -420,12 +425,12 @@ def video_tag(sources, options = {})
options[:width], options[:height] = size.split("x") if size =~ %r{^\d+x\d+$}
end
- if sources.is_a?(Array)
+ if sources.size > 1
content_tag("video", options) do
- sources.map { |source| tag("source", :src => path_to_video(source)) }.join.html_safe
+ safe_join sources.map { |source| tag("source", :src => path_to_video(source)) }
end
else
- options[:src] = path_to_video(sources)
+ options[:src] = path_to_video(sources.first)
tag("video", options)
end
end
@@ -441,15 +446,18 @@ def video_tag(sources, options = {})
#
# audio_tag("sound.wav", :autoplay => true, :controls => true) # =>
#
- def audio_tag(sources, options = {})
- options.symbolize_keys!
+ # audio_tag("sound.wav", "sound.mid") # =>
+ #
+ def audio_tag(*sources)
+ options = sources.extract_options!.symbolize_keys!
+ sources.flatten!
- if sources.is_a?(Array)
+ if sources.size > 1
content_tag("audio", options) do
- sources.collect { |source| tag("source", :src => path_to_audio(source)) }.join.html_safe
+ safe_join sources.collect { |source| tag("source", :src => path_to_audio(source)) }
end
else
- options[:src] = path_to_audio(sources)
+ options[:src] = path_to_audio(sources.first)
tag("audio", options)
end
end
diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb
index 45a8492d58c290b59f449ddee61c1ec2aab73021..37153ee96009fb53f7e96c273be3f67b93814493 100644
--- a/actionpack/test/template/asset_tag_helper_test.rb
+++ b/actionpack/test/template/asset_tag_helper_test.rb
@@ -201,6 +201,7 @@ def teardown
%(video_tag("error.avi", "size" => "x")) => %(),
%(video_tag("http://media.rubyonrails.org/video/rails_blog_2.mov")) => %(),
%(video_tag("//media.rubyonrails.org/video/rails_blog_2.mov")) => %(),
+ %(video_tag("multiple.ogg", "multiple.avi")) => %(),
%(video_tag(["multiple.ogg", "multiple.avi"])) => %(),
%(video_tag(["multiple.ogg", "multiple.avi"], :size => "160x120", :controls => true)) => %()
}
@@ -224,6 +225,7 @@ def teardown
%(audio_tag("rss.wav", :autoplay => true, :controls => true)) => %(),
%(audio_tag("http://media.rubyonrails.org/audio/rails_blog_2.mov")) => %(),
%(audio_tag("//media.rubyonrails.org/audio/rails_blog_2.mov")) => %(),
+ %(audio_tag("audio.mp3", "audio.ogg")) => %(),
%(audio_tag(["audio.mp3", "audio.ogg"])) => %(),
%(audio_tag(["audio.mp3", "audio.ogg"], :autobuffer => true, :controls => true)) => %()
}