Module: Shipyard::Rails::ButtonHelper

Defined in:
lib/shipyard-framework/rails/button_helper.rb

Instance Method Summary collapse

Instance Method Details

#btn(name, *args, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/shipyard-framework/rails/button_helper.rb', line 4

def btn(name, *args, &block)
  if block_given?
    args << name
    name = capture(&block)
  end

  # Save any options that were passed in.
  options = {}
  args.each do |arg|
    options = options.merge(arg) if arg.is_a?(Hash)
  end

  # Output the appropriate button.
  if options.key?(:href)
    link_to name, options[:href], btn_options(args, options)
  else
     :button, name, btn_options(args, options)
  end
end