aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorJanko Marohnić <janko.marohnic@gmail.com>2012-01-25 11:52:49 +0100
committerJanko Marohnić <janko.marohnic@gmail.com>2012-01-25 11:52:49 +0100
commit7d93e814e6cbdf78f4190cba36c1edb8e8d42ff6 (patch)
tree4ad3b0e6093a459277743fa7cc9f77ee85ac3144 /actionpack/lib/action_view
parent3339293280c12b1335d193c7f49c3e6ea665e76d (diff)
downloadrails-7d93e814e6cbdf78f4190cba36c1edb8e8d42ff6.tar.gz
rails-7d93e814e6cbdf78f4190cba36c1edb8e8d42ff6.tar.bz2
rails-7d93e814e6cbdf78f4190cba36c1edb8e8d42ff6.zip
Make audio_tag able to receive multiple sources
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index 9b4b3923b6..134eaab8bc 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -441,10 +441,17 @@ module ActionView
# <audio src="/audios/sound.wav" />
# audio_tag("sound.wav", :autoplay => true, :controls => true) # =>
# <audio autoplay="autoplay" controls="controls" src="/audios/sound.wav" />
- def audio_tag(source, options = {})
+ def audio_tag(sources, options = {})
options.symbolize_keys!
- options[:src] = path_to_audio(source)
- tag("audio", options)
+
+ if sources.is_a?(Array)
+ content_tag("audio", options) do
+ sources.collect { |source| tag("source", :src => path_to_audio(source)) }.join.html_safe
+ end
+ else
+ options[:src] = path_to_audio(sources)
+ tag("audio", options)
+ end
end
private