diff options
author | Janko Marohnić <janko.marohnic@gmail.com> | 2012-01-25 11:52:49 +0100 |
---|---|---|
committer | Janko Marohnić <janko.marohnic@gmail.com> | 2012-01-25 11:52:49 +0100 |
commit | 7d93e814e6cbdf78f4190cba36c1edb8e8d42ff6 (patch) | |
tree | 4ad3b0e6093a459277743fa7cc9f77ee85ac3144 /actionpack/lib | |
parent | 3339293280c12b1335d193c7f49c3e6ea665e76d (diff) | |
download | rails-7d93e814e6cbdf78f4190cba36c1edb8e8d42ff6.tar.gz rails-7d93e814e6cbdf78f4190cba36c1edb8e8d42ff6.tar.bz2 rails-7d93e814e6cbdf78f4190cba36c1edb8e8d42ff6.zip |
Make audio_tag able to receive multiple sources
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/asset_tag_helper.rb | 13 |
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 |