Module: Bh::DropdownHelper
- Includes:
- BaseHelper
- Defined in:
- lib/bh/helpers/dropdown_helper.rb
Overview
Provides methods to include dropdowns.
Instance Method Summary collapse
-
#dropdown(caption, options = {}) { ... } ⇒ String
Returns an HTML block tag that follows the Bootstrap documentation on how to display dropdowns.
Instance Method Details
#dropdown(caption, options = {}) { ... } ⇒ String
Returns an HTML block tag that follows the Bootstrap documentation on how to display dropdowns.
The skeleton of the dropdown is an unordered list; its content is passed as block to the list of dropdown items. Since the most common use for a dropdown is to display a menu of links, a variable is set inside the block so that every call to +link_to+ generates a link surrounded by a list item and with the appropriate menu item attributes.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bh/helpers/dropdown_helper.rb', line 43 def dropdown(caption, = {}, &block) ||= {} [:id] ||= "dropdown-#{rand 10**10}" [:caption] = caption [:div_class] = dropdown_div_class [:button_class] = [:list_class] = dropdown_list_class layout = [:split] ? 'bh/dropdown_split' : 'bh/dropdown' @dropdown_link = true dropdown = render layout: layout, locals: , &block dropdown.tap{ @dropdown_link = false } end |