From b608d54db67b99f92ad7ce1e30f80f40d73b724f Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Fri, 3 Jul 2009 09:29:30 -0300 Subject: [PATCH] Adds a audio_tag helper for the HTML5 audio tag. Fixed video_path docs. HTML attributes values should be true or false not attribute's name. --- .../lib/action_view/helpers/asset_tag_helper.rb | 38 +++++++++++++++++- actionpack/lib/action_view/helpers/tag_helper.rb | 3 +- actionpack/test/template/asset_tag_helper_test.rb | 40 ++++++++++++++++++-- 3 files changed, 72 insertions(+), 9 deletions(-) diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index a3b9932..2ec79ad 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -462,12 +462,27 @@ module ActionView # video_path("hd") # => /videos/hd # video_path("hd.avi") # => /videos/hd.avi # video_path("trailers/hd.avi") # => /videos/trailers/hd.avi - # video_path("/trailers/hd.avi") # => /videos/hd.avi + # video_path("/trailers/hd.avi") # => /trailers/hd.avi # video_path("http://www.railsapplication.com/vid/hd.avi") # => http://www.railsapplication.com/vid/hd.avi def video_path(source) compute_public_path(source, 'videos') end - alias_method :path_to_video, :video_path # aliased to avoid conflicts with an video_path named route + alias_method :path_to_video, :video_path # aliased to avoid conflicts with a video_path named route + + # Computes the path to an audio asset in the public audios directory. + # Full paths from the document root will be passed through. + # Used internally by +audio_tag+ to build the audio path. + # + # ==== Examples + # audio_path("horse") # => /audios/horse + # audio_path("horse.wav") # => /audios/horse.avi + # audio_path("sounds/horse.wav") # => /audios/sounds/horse.avi + # audio_path("/sounds/horse.wav") # => /sounds/horse.avi + # audio_path("http://www.railsapplication.com/sounds/horse.wav") # => http://www.railsapplication.com/sounds/horse.wav + def audio_path(source) + compute_public_path(source, 'audios') + end + alias_method :path_to_audio, :audio_path # aliased to avoid conflicts with an audio_path named route # Returns an html image tag for the +source+. The +source+ can be a full # path or a file that exists in your public images directory. @@ -542,7 +557,7 @@ module ActionView # video_tag("trailer.ogg") # => #