Module: RailsBootstrapHelpers::Helpers::ButtonHelper
- Includes:
- FormTagHelper, OptionsHelper
- Defined in:
- lib/rails-bootstrap-helpers/helpers/button_helper.rb
Instance Method Summary collapse
-
#bs_button_to(*args, &block) ⇒ Object
Renders a Bootstrap button.
-
#bs_collapsible_button(text, target, options = {}) ⇒ Object
Renders a collapsible Bootstrap button.
-
#bs_dropdown_button_to(text, url_or_options = nil, options = {}, &block) ⇒ Object
Renders a dropdown button.
-
#bs_inline_button_to(url, icon, options = {}) ⇒ Object
Renders an inline Bootstrap button.
-
#bs_popover_button(name, content_or_options = nil, options = {}, &block) ⇒ Object
Renders a Bootstrap button with a popover.
-
#button_group(options = {}, &block) ⇒ Object
Returns a button group.
Methods included from FormTagHelper
#bs_button_tag, #bs_submit_tag
Methods included from OptionsHelper
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:
18 19 20 |
# File 'lib/rails-bootstrap-helpers/helpers/button_helper.rb', line 18 def (*args, &block) RailsBootstrapHelpers::Renderers::ButtonRenderer.new(self, :link, *args, &block).render end |
#bs_collapsible_button(text, target, options = {}) ⇒ Object
Renders a collapsible Bootstrap button. That is, a button when clicked opens a collapsible section.
78 79 80 81 82 83 |
# File 'lib/rails-bootstrap-helpers/helpers/button_helper.rb', line 78 def (text, target, = {}) = .dup.reverse_merge :"data-toggle" => "collapse", :"data-target" => target text, :button, end |
#bs_dropdown_button_to(text, url_or_options = nil, options = {}, &block) ⇒ Object
Renders a dropdown button.
All options are passed to the underlying button.
124 125 126 |
# File 'lib/rails-bootstrap-helpers/helpers/button_helper.rb', line 124 def (text, = nil, = {}, &block) RailsBootstrapHelpers::Renderers::DropdownButtonRenderer.new(self, text, , , &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.
30 31 32 33 34 |
# File 'lib/rails-bootstrap-helpers/helpers/button_helper.rb', line 30 def (url, icon, = {}) = .reverse_merge icon: icon, size: "mini" append_class!(, "inline") RailsBootstrapHelpers::Renderers::ButtonRenderer.new(self, :link, nil, url, ).render end |
#bs_popover_button(name, content_or_options = nil, options = {}, &block) ⇒ Object
Renders a Bootstrap button with a popover.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rails-bootstrap-helpers/helpers/button_helper.rb', line 48 def (name, = nil, = {}, &block) if block_given? (name, capture(&block).gsub("\n", ""), || {}) else = .deep_dup placement = .delete(:placement) if placement ActiveSupport::Deprecation.warn "Usage of the option `:placement` is deprecated. Please use the `:position` option instead" end position = .delete(:position) || placement || "bottom" = .reverse_merge :"data-content" => , :"data-toggle" => "popover", :"data-placement" => position (name, '#', ) end end |
#button_group(options = {}, &block) ⇒ Object
Returns a button group. That is, a div tag with the “btn-group” class.
All other options are passed to the button group div.
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/rails-bootstrap-helpers/helpers/button_helper.rb', line 96 def ( = {}, &block) if = .delete(:toolbar) append_class!(, "btn-toolbar") else append_class!(, "btn-group") append_class!(, "btn-group-vertical") if .delete(:vertical) end content_tag(:div, , &block) end |