Ruby Button Helper
Join the DZone community and get the full member experience.
Join For FreeI use this for the admin section of my sites. It's good for your basic buttons. I use the tango icon library as well (http://tango.freedesktop.org/Tango_Icon_Gallery).
def button(options = {})
image_source = case options[:type]
when 'edit': "edit-find-replace.png"
when 'preview': "document-print-preview.png"
when 'delete': "edit-delete.png"
else "list-add.png"
end
button = "
"
if options[:link]
target = params[:target].blank? ? ">" : " target='#{options[:target]}'>"
""
else
button
end
end
Example usage:
<%= button %>
#
<%= button :type => "edit", :link => "/edit/5" %>
Opinions expressed by DZone contributors are their own.
Comments