Module: RailsBootstrapHelpers::Helpers::ButtonHelper

Defined in:
lib/rails-bootstrap-helpers/helpers/button_helper.rb

Instance Method Summary collapse

Instance Method Details

#bs_button_to(*args, &block) ⇒ Object

Renders a Bootstrap button. This method behaves just as “link_to” but will render a Bootstrap button instead of a regular link. Note that this is still an “a” tag and not an “input” tag. In addition to the options “link_to” handles this method also handles the following options:

Options



15
16
17
# File 'lib/rails-bootstrap-helpers/helpers/button_helper.rb', line 15

def bs_button_to (*args, &block)
  RailsBootstrapHelpers::Renderers::ButtonRenderer.new(self, :link, *args, &block).render
end

#bs_inline_button_to(url, icon, options = {}) ⇒ Object

Renders an inline Bootstrap button. That is, a small button having only an icon and no text.

See Also:



27
28
29
30
# File 'lib/rails-bootstrap-helpers/helpers/button_helper.rb', line 27

def bs_inline_button_to (url, icon, options = {})
  options = options.reverse_merge icon: icon, size: "mini"
  RailsBootstrapHelpers::Renderers::ButtonRenderer.new(self, :link, nil, url, options).render
end

#bs_popover_button(name, content_or_options = nil, options = {}, &block) ⇒ Object

Renders a Bootstrap button with a popover.

Options



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rails-bootstrap-helpers/helpers/button_helper.rb', line 42

def bs_popover_button (name, content_or_options = nil, options = {}, &block)
  if block_given?
    bs_popover_button(name, capture(&block).gsub("\n", ""), content_or_options || {})
  else
    placement = options.delete(:placement) || "bottom"

    options = options.reverse_merge :"data-content" => content_or_options,
      :"data-toggle" => "popover",
      :"data-placement" => placement

    bs_button_to(name, '#', options)
  end
end