Over a million developers have joined DZone.

Ruby Button Helper

·
I 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" %>
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}