Module: Bootstrap::AccordionHelper
- Defined in:
- app/helpers/bootstrap/accordion_helper.rb
Overview
Rails helpers for building Bootstrap accordions.
See: twitter.github.io/bootstrap/javascript.html#collapse
<%= accordion do %>
<%= accordion_group('Section 1', open: true) do %>
content for group 1
<% end >
<%= accordion_group('Section 1') do %>
content for group 2
<% end %>
<% end %>
Instance Method Summary collapse
-
#accordion(options = {}) { ... } ⇒ String
Returns the html for a Bootstrap accordion.
-
#accordion_group(text, options = {}) { ... } ⇒ Object
Returns the html for a Bootstrap accordion group.
Instance Method Details
#accordion(options = {}) { ... } ⇒ String
Returns the html for a Bootstrap accordion.
25 26 27 28 29 30 31 32 33 34 |
# File 'app/helpers/bootstrap/accordion_helper.rb', line 25 def accordion(={}) = () = ensure_accordion_id() @accordion_id = [:id] = ensure_class(, 'panel-group') content_tag(:div, ) do yield end end |
#accordion_group(text, options = {}) { ... } ⇒ Object
Returns the html for a Bootstrap accordion group.
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/helpers/bootstrap/accordion_helper.rb', line 43 def accordion_group(text, ={}) = () open = .delete(:open) # options = ensure_accordion_group_id(options) @accordion_group_id = get_next_group_id = ensure_class(, 'panel panel-default') content_tag(:div, ) do accordion_group_heading(text) + accordion_group_body(open) { yield } end end |