Class: BootstrapComponentsHelpers::AccordionHelper::AccordionBuilder
- Inherits:
-
Object
- Object
- BootstrapComponentsHelpers::AccordionHelper::AccordionBuilder
- Defined in:
- lib/bootstrap-components-helpers/accordion_helper.rb
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
-
#initialize(opts, parent) ⇒ AccordionBuilder
constructor
A new instance of AccordionBuilder.
- #pane(title, options = {}, &block) ⇒ Object
Constructor Details
#initialize(opts, parent) ⇒ AccordionBuilder
Returns a new instance of AccordionBuilder.
18 19 20 21 |
# File 'lib/bootstrap-components-helpers/accordion_helper.rb', line 18 def initialize opts, parent @parent = parent @opts = opts end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
15 16 17 |
# File 'lib/bootstrap-components-helpers/accordion_helper.rb', line 15 def parent @parent end |
Instance Method Details
#pane(title, options = {}, &block) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bootstrap-components-helpers/accordion_helper.rb', line 23 def pane title, = {}, &block css_class = [:open] ? 'in' : '' content_tag :div, :class => 'panel panel-default' do heading = content_tag :div, :class => 'panel-heading' do content_tag :h4, :class => 'panel-title' do link_to title, "##{title.parameterize}_pane", :'data-toggle' => 'collapse', :'data-parent' => "##{@opts[:accordion_id]}" end end body = content_tag :div, :class => "panel-collapse collapse #{css_class}", :id => "#{title.parameterize}_pane" do content_tag :div, :class => 'panel-body' do capture(&block) end end heading + body end end |