Module: SexybuttonHelper

Defined in:
app/helpers/sexybutton_helper.rb

Defined Under Namespace

Classes: SexyButton

Instance Method Summary collapse

Instance Method Details

#include_sexybuttonsObject



3
4
5
# File 'app/helpers/sexybutton_helper.rb', line 3

def include_sexybuttons
  tag(:link, :type => 'text/css', :media => 'screen', :rel => 'stylesheet', :href => '/components/SexyButtons/sexybuttons.css')
end

#sexybutton(text, url = nil, image = nil) {|btn| ... } ⇒ Object

Yields:

  • (btn)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/helpers/sexybutton_helper.rb', line 7

def sexybutton(text, url = nil, image = nil)
  tag_name = 'button'

  btn = SexyButton.new
  yield btn if block_given?

  image ||= btn.image
  html_class = "sexybutton sexysimple sexy#{btn.color}" 
  if btn.style
    html_class << " #{btn.style}"
  end
  html_options = btn.html_options.merge! :class => html_class 
  html_options.merge! :type => btn.type if btn.type
  html_options.merge! :id => btn.id if btn.id
  if url
    html_options.merge! :href => url 
    tag_name = 'a'
  end

  content = image.nil? ? text : (:span, text, :class => image)
  (tag_name, content, html_options)
end