Class: TwitterBootstrapMarkup::Tag
- Inherits:
-
Object
- Object
- TwitterBootstrapMarkup::Tag
- Includes:
- Popover, SidePosition, Tooltip
- Defined in:
- lib/twitter_bootstrap_markup/tag.rb
Direct Known Subclasses
AddOn, Alert, Badge, Brand, Breadcrumb, Button, ControlGroup, Divider, DropdownButton, DropdownLink, ExtendedInput, Fieldset, Form, GridColumn, GridRow, Help, Icon, Input, Label, Link, LinkButton, NavBar, NavHeader, PageHeader, Pagination, ProgressBar, Select, Tab, TabContent, Table, Textarea, UlContainer, Well
Constant Summary
Constants included from Popover
Constants included from Tooltip
TwitterBootstrapMarkup::Tooltip::POSITIONS
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #append(element = nil, &block) ⇒ Object
-
#initialize(*args, &block) ⇒ Tag
constructor
A new instance of Tag.
- #prepend(element) ⇒ Object
- #to_s ⇒ Object
Methods included from SidePosition
Methods included from Popover
Methods included from Tooltip
Constructor Details
#initialize(*args, &block) ⇒ Tag
Returns a new instance of Tag.
23 24 25 26 27 28 29 30 31 |
# File 'lib/twitter_bootstrap_markup/tag.rb', line 23 def initialize(*args, &block) @name = args.shift content = args.shift unless args.first.is_a?(Hash) @attributes = args.shift || {} @children = [] @is_block = content || block_given? append content if content evaluate(&block) if block_given? end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
8 9 10 |
# File 'lib/twitter_bootstrap_markup/tag.rb', line 8 def attributes @attributes end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
9 10 11 |
# File 'lib/twitter_bootstrap_markup/tag.rb', line 9 def children @children end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/twitter_bootstrap_markup/tag.rb', line 7 def name @name end |
Class Method Details
Instance Method Details
#append(element = nil, &block) ⇒ Object
33 34 35 36 37 |
# File 'lib/twitter_bootstrap_markup/tag.rb', line 33 def append(element=nil, &block) element = evaluate(&block) if block_given? @children << element element end |
#prepend(element) ⇒ Object
39 40 41 |
# File 'lib/twitter_bootstrap_markup/tag.rb', line 39 def prepend(element) @children.insert 0, element end |
#to_s ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/twitter_bootstrap_markup/tag.rb', line 43 def to_s attributes_markup = attributes.empty? ? '' : " #{attributes.map{|key, value| "#{key}#{value ? "=\"#{value}\"" : ''}"}.join(' ')}" if @is_block "<#{name}#{attributes_markup}>#{children.map(&:to_s).join}</#{name}>" else "<#{name}#{attributes_markup}>" end end |