From 47fbc79dbe5ab7cbebbb546fb659c467a89b9648 Mon Sep 17 00:00:00 2001 From: Michael Deering Date: Thu, 24 Sep 2009 00:09:56 -0600 Subject: [PATCH] Allowing image_tag to passthrough the escape option properly through to the tag call --- .../lib/action_view/helpers/asset_tag_helper.rb | 8 ++++++-- actionpack/test/template/asset_tag_helper_test.rb | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index 95f00cd..2f906ea 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -504,6 +504,7 @@ module ActionView # * :mouseover - Set an alternate image to be used when the onmouseover # event is fired, and sets the original image to be replaced onmouseout. # This can be used to implement an easy image toggle that fires on onmouseover. + # * :escape - Defaults to true if not given. If false values will not get escaped. # # ==== Examples # image_tag("icon") # => @@ -522,6 +523,8 @@ module ActionView # Mouse # image_tag("mouse.png", :mouseover => image_path("mouse_over.png")) # => # Mouse + # image_tag("/escape.html?foo=bar&something=something-else", :escape => false) # => + # Escape def image_tag(source, options = {}) options.symbolize_keys! @@ -536,8 +539,9 @@ module ActionView options[:onmouseover] = "this.src='#{image_path(mouseover)}'" options[:onmouseout] = "this.src='#{src}'" end - - tag("img", options) + + escape = options.delete(:escape) + tag("img", options, false, escape.nil? ? true : escape) end # Returns an html video tag for the +sources+. If +sources+ is a string, diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index 83fc6a2..367583a 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -142,6 +142,8 @@ class AssetTagHelperTest < ActionView::TestCase %(image_tag("error.png", "size" => "45 x 70")) => %(Error), %(image_tag("error.png", "size" => "x")) => %(Error), %(image_tag("http://www.rubyonrails.com/images/rails.png")) => %(Rails), + %(image_tag("/escape.html?foo=bar&something=something-else")) => %(Escape), + %(image_tag("/escape.html?foo=bar&something=something-else", :escape => false)) => %(Escape), %(image_tag("mouse.png", :mouseover => "/images/mouse_over.png")) => %(Mouse), %(image_tag("mouse.png", :mouseover => image_path("mouse_over.png"))) => %(Mouse) } -- 1.6.3.1