Module: Bootstrap::DropdownHelper
- Includes:
- ActionView::Helpers::SanitizeHelper
- Defined in:
- app/helpers/bootstrap/dropdown_helper.rb
Overview
Rails helper methods for various Bootstrap dropdown menus
Instance Method Summary collapse
-
#button_dropdown(*args) { ... } ⇒ Object
Returns a Bootstrap button dropdown.
-
#dropdown_divider ⇒ String
Returns a divider for various dropdowns.
-
#dropdown_item(*args) ⇒ String
Returns a link for use within various *_dropdown methods.
-
#nav_dropdown(text, options = {}) { ... } ⇒ String
Returns a drop-down menu of links.
-
#split_button_dropdown(*args) { ... } ⇒ String
Returns a Bootstrap split-button dropdown.
Instance Method Details
#button_dropdown('Text') ⇒ Object #button_dropdown('Text', : info) ⇒ Object #button_dropdown('Text', : info, : mini) ⇒ Object
Returns a Bootstrap button dropdown
Parameters have same semantics as in ButtonHelper#button
53 54 55 56 57 |
# File 'app/helpers/bootstrap/dropdown_helper.rb', line 53 def (*args) content_tag(:div, class: 'btn-group') do (*args) + dropdown_ul { yield } end end |
#dropdown_divider ⇒ String
Returns a divider for various dropdowns
95 96 97 |
# File 'app/helpers/bootstrap/dropdown_helper.rb', line 95 def dropdown_divider content_tag(:li, nil, class: 'divider') end |
#dropdown_item('Text') ⇒ String #dropdown_item('Text', url: '/url') ⇒ String
Returns a link for use within various *_dropdown methods
81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/helpers/bootstrap/dropdown_helper.rb', line 81 def dropdown_item(*args) = args. text = args.shift or raise "Need text to link to" url = args.shift || 'javascript:void(0)' = ensure_class(, 'dropdown') content_tag(:li) do link_to(text, url, ) end end |
#nav_dropdown(text, options = {}) { ... } ⇒ String
Returns a drop-down menu of links
Usually called from yielded block of NavHelper#nav_bar
36 37 38 39 40 41 42 43 |
# File 'app/helpers/bootstrap/dropdown_helper.rb', line 36 def nav_dropdown(text, ={}) = () = ensure_class(, 'nav-item dropdown') content_tag(:li, ) do nav_dropdown_link(text) + dropdown_ul { yield } end end |
#split_button_dropdown('Text') ⇒ String #split_button_dropdown('Text', url: '/url') ⇒ String #split_button_dropdown('Text', : large, : danger, url: '/url') ⇒ String
Returns a Bootstrap split-button dropdown
Parameters have same semantics as in ButtonHelper#button
68 69 70 71 72 73 74 |
# File 'app/helpers/bootstrap/dropdown_helper.rb', line 68 def (*args) extras = extract_extras(*args) content_tag(:div, class: 'btn-group') do (*args) + (extras) + dropdown_ul { yield } end end |