Class: Bootstrap::ViewHelpers::Components::Button

Inherits:
Bootstrap::ViewHelpers::Component show all
Defined in:
lib/bootstrap/view_helpers/components/button.rb,
lib/bootstrap/view_helpers/components/button/link.rb,
lib/bootstrap/view_helpers/components/button/close.rb,
lib/bootstrap/view_helpers/components/button/radio.rb,
lib/bootstrap/view_helpers/components/button/checkbox.rb,
lib/bootstrap/view_helpers/components/button/button_type_not_found_error.rb

Direct Known Subclasses

Accordion::Button, Checkbox, Close, Link, Radio

Defined Under Namespace

Classes: ButtonTypeNotFoundError, Checkbox, Close, Link, Radio

Constant Summary collapse

TYPES =
{
  button: Button,
  checkbox: Button::Checkbox,
  close: Button::Close,
  link: Button::Link,
  radio: Button::Radio
}

Instance Attribute Summary

Attributes inherited from Bootstrap::ViewHelpers::Component

#block, #options, #style, #view

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Bootstrap::ViewHelpers::Component

#initialize

Constructor Details

This class inherits a constructor from Bootstrap::ViewHelpers::Component

Class Method Details

.build(view_context, options, &block) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/bootstrap/view_helpers/components/button.rb', line 21

def build(view_context, options, &block)
  type = options.delete(:type) || defaults[:type]
  options[:type] = options[:html_type]
  unless TYPES.keys.include? type
    raise ButtonTypeNotFoundError, type
  end
  TYPES[type].new(view_context, options, &block)
end

Instance Method Details

#to_htmlObject



37
38
39
# File 'lib/bootstrap/view_helpers/components/button.rb', line 37

def to_html
  (:button, label, html_options)
end