diff options
author | Nishant Modak <modak.nishant@gmail.com> | 2015-11-20 18:17:23 +0530 |
---|---|---|
committer | Nishant Modak <modak.nishant@gmail.com> | 2015-11-20 23:16:53 +0530 |
commit | 5d45eed2ab9b029da5f6daac4a2834dec2c6bd3d (patch) | |
tree | 27f8ba6b7e8456d4cbf8a64f01363af7b73d4a59 /actionview | |
parent | f6d12b8ea235e5b9c1d23edbff88765d7882ce94 (diff) | |
download | rails-5d45eed2ab9b029da5f6daac4a2834dec2c6bd3d.tar.gz rails-5d45eed2ab9b029da5f6daac4a2834dec2c6bd3d.tar.bz2 rails-5d45eed2ab9b029da5f6daac4a2834dec2c6bd3d.zip |
Example of setting data attributes for image_tag
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/lib/action_view/helpers/asset_tag_helper.rb | 2 | ||||
-rw-r--r-- | actionview/test/template/asset_tag_helper_test.rb | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/actionview/lib/action_view/helpers/asset_tag_helper.rb b/actionview/lib/action_view/helpers/asset_tag_helper.rb index 2ffed6b395..91e934cd64 100644 --- a/actionview/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionview/lib/action_view/helpers/asset_tag_helper.rb @@ -205,6 +205,8 @@ module ActionView # # => <img alt="Icon" height="32" src="/icons/icon.gif" width="32" /> # image_tag("/icons/icon.gif", class: "menu_icon") # # => <img alt="Icon" class="menu_icon" src="/icons/icon.gif" /> + # image_tag("/icons/icon.gif", data: { title: 'Rails Application' }) + # # => <img data-title="Rails Application" src="/icons/icon.gif" /> def image_tag(source, options={}) options = options.symbolize_keys check_for_image_tag_errors(options) diff --git a/actionview/test/template/asset_tag_helper_test.rb b/actionview/test/template/asset_tag_helper_test.rb index a63ac442cd..fe40010528 100644 --- a/actionview/test/template/asset_tag_helper_test.rb +++ b/actionview/test/template/asset_tag_helper_test.rb @@ -193,7 +193,8 @@ class AssetTagHelperTest < ActionView::TestCase %(image_tag("//www.rubyonrails.com/images/rails.png")) => %(<img alt="Rails" src="//www.rubyonrails.com/images/rails.png" />), %(image_tag("mouse.png", :alt => nil)) => %(<img src="/images/mouse.png" />), %(image_tag("data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==", :alt => nil)) => %(<img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" />), - %(image_tag("")) => %(<img src="" />) + %(image_tag("")) => %(<img src="" />), + %(image_tag("gold.png", data: { title: 'Rails Application' })) => %(<img data-title="Rails Application" src="/images/gold.png" alt="Gold" />) } FaviconLinkToTag = { |