Class: BootstrapHelpers::TabsBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/bootstrap-helpers.rb

Overview

Tabs =

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ TabsBuilder

Returns a new instance of TabsBuilder.



233
234
235
236
237
238
# File 'lib/bootstrap-helpers.rb', line 233

def initialize parent
  @first = true
  @parent = parent
  @pane_handles = []
  @pane_contents = []
end

Instance Attribute Details

#pane_contentsObject (readonly)

Returns the value of attribute pane_contents.



230
231
232
# File 'lib/bootstrap-helpers.rb', line 230

def pane_contents
  @pane_contents
end

#pane_handlesObject (readonly)

Returns the value of attribute pane_handles.



230
231
232
# File 'lib/bootstrap-helpers.rb', line 230

def pane_handles
  @pane_handles
end

#parentObject (readonly)

Returns the value of attribute parent.



230
231
232
# File 'lib/bootstrap-helpers.rb', line 230

def parent
  @parent
end

Instance Method Details

#pane(title, pane_id = nil, &block) ⇒ Object



240
241
242
243
244
245
246
247
248
249
# File 'lib/bootstrap-helpers.rb', line 240

def pane(title, pane_id = nil, &block)
  pane_id ||= "#{title.parameterize}_tab"
  css_class, @first = 'active', false if @first
  link = (:a, title, :'data-toggle' => 'tab', :href => "##{pane_id}")
  @pane_handles << (:li, link, :class => css_class)
  @pane_contents << ( :div, :class => "tab-pane #{css_class}", :id => "#{pane_id}" do
    capture(&block)
  end)
  nil
end