Class: TwitterBootstrapMarkup::DropdownButton

Inherits:
Tag
  • Object
show all
Defined in:
lib/twitter_bootstrap_markup/dropdown_button.rb

Constant Summary

Constants included from Popover

Popover::POSITIONS

Constants included from Tooltip

Tooltip::POSITIONS

Instance Attribute Summary

Attributes inherited from Tag

#attributes, #children, #name

Instance Method Summary collapse

Methods inherited from Tag

block, inline, #prepend, #to_s

Methods included from SidePosition

#pull_left, #pull_right

Methods included from Popover

#popover

Methods included from Tooltip

#tooltip

Constructor Details

#initialize(text, &block) ⇒ DropdownButton

Returns a new instance of DropdownButton.



5
6
7
8
9
10
11
12
13
14
# File 'lib/twitter_bootstrap_markup/dropdown_button.rb', line 5

def initialize(text, &block)
  super(:div, :class => 'btn-group') do
    @button = internal_append(Button.new(:class => 'dropdown-toggle', 'data-toggle' => 'dropdown') do
      append "#{text} "
      append Tag.block :span, :class => 'caret'
    end)
    @ul = internal_append Tag.block(:ul, :class => 'dropdown-menu')
    instance_eval &block if block_given?
  end
end

Instance Method Details

#append(element) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/twitter_bootstrap_markup/dropdown_button.rb', line 16

def append(element)
  if element.is_a?(Tag) && element.name == :li
    @ul.append element
  else
    @ul.append Tag.block(:li, element)
  end
end

#internal_appendObject



3
# File 'lib/twitter_bootstrap_markup/dropdown_button.rb', line 3

alias :internal_append :append