Module: Bootstrap::DropdownHelper
- 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) { ... } ⇒ 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
49 50 51 52 53 |
# File 'app/helpers/bootstrap/dropdown_helper.rb', line 49 def (*args) content_tag(:div, class: 'btn-group') do (*args) + dropdown_ul { yield } end end |
#dropdown_divider ⇒ String
Returns a divider for various dropdowns
89 90 91 |
# File 'app/helpers/bootstrap/dropdown_helper.rb', line 89 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
77 78 79 80 81 82 83 84 85 |
# File 'app/helpers/bootstrap/dropdown_helper.rb', line 77 def dropdown_item(*args) = args. text = args.shift or raise "Need text to link to" url = args.shift || 'javascript:void(0)' content_tag(:li) do link_to(text, url, ) end end |
#nav_dropdown(text) { ... } ⇒ String
Returns a drop-down menu of links
Usually called from yielded block of NavHelper#nav_bar
35 36 37 38 39 |
# File 'app/helpers/bootstrap/dropdown_helper.rb', line 35 def nav_dropdown(text) content_tag(:li, class: 'dropdown') 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
64 65 66 67 68 69 70 |
# File 'app/helpers/bootstrap/dropdown_helper.rb', line 64 def (*args) extras = extract_extras(*args) content_tag(:div, class: 'btn-group') do (*args) + (extras) + dropdown_ul { yield } end end |