Module: Shipyard::ButtonHelper

Includes:
ActionView::Helpers::TagHelper, ActionView::Helpers::UrlHelper
Included in:
Jekyll::Button
Defined in:
lib/shipyard-framework/helpers/button_helper.rb

Instance Method Summary collapse

Instance Method Details

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



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

def btn(text, *args, &block)
  if block_given?
    args << text
    text = 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)
    options[:role] = :button
    link_to text, options[:href], btn_options(args, options)
  else
     :button, text, btn_options(args, options)
  end
end