relying on ActionView's helper methods to construct the HTML

This commit is contained in:
Donald Ball 2008-11-23 22:54:53 -06:00
parent 06888a9039
commit 79b5706eda
2 changed files with 5 additions and 3 deletions

View File

@ -2,7 +2,9 @@ module Zoomifier
module ViewHelpers module ViewHelpers
def zoomify_image_tag(source, options = {}) def zoomify_image_tag(source, options = {})
raise ArgumentError unless options[:id] raise ArgumentError unless options[:id]
"<div id=\"#{options[:id]}\"><img src=\"#{source}\" alt=\"\"/></div>" content_tag :div, { :id => options[:id] } do
image_tag source, options.merge({ :id => nil })
end
end end
end end
end end

View File

@ -16,7 +16,7 @@ describe Zoomifier::ViewHelpers do
end end
it "should generate the zoomify markup" do it "should generate the zoomify markup" do
@view.zoomify_image_tag('foo.jpg', { :id => 'foo' }).should == @view.zoomify_image_tag('foo.jpg', { :id => 'foo', :alt => 'Foo Bar' }).should ==
'<div id="foo"><img src="foo.jpg" alt=""/></div>' '<div id="foo"><img alt="Foo Bar" src="/images/foo.jpg" /></div>'
end end
end end