Class: Bootstrap::Component

Inherits:
Object show all
Extended by:
ComponentClass
Includes:
BasicTags, Delegate
Defined in:
card-mod-bootstrap/lib/bootstrap/component.rb,
card-mod-bootstrap/lib/bootstrap/component/form.rb,
card-mod-bootstrap/lib/bootstrap/component/panel.rb,
card-mod-bootstrap/lib/bootstrap/component/layout.rb,
card-mod-bootstrap/lib/bootstrap/component/carousel.rb,
card-mod-bootstrap/lib/bootstrap/component/component_class.rb,
card-mod-bootstrap/lib/bootstrap/component/horizontal_form.rb

Overview

render components of bootstrap library

Direct Known Subclasses

Carousel, Form, OldComponent

Defined Under Namespace

Modules: ComponentClass Classes: Carousel, Form, HorizontalForm, Layout, Panel

Instance Method Summary collapse

Methods included from ComponentClass

def_div_method, def_tag_method

Methods included from Delegate

#method_missing, #respond_to_missing?

Methods included from BasicTags

#html

Constructor Details

#initialize(context, *args, &block) ⇒ Component

Returns a new instance of Component.



6
7
8
9
10
11
12
13
14
15
# File 'card-mod-bootstrap/lib/bootstrap/component.rb', line 6

def initialize context, *args, &block
  @context = context
  @content = ["".html_safe]
  @args = args
  @child_args = []
  @append = []
  @wrap = []
  @build_block = block
  @html = Builder::XmlMarkup.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Bootstrap::Delegate

Instance Method Details

#append(&block) ⇒ Object



31
32
33
# File 'card-mod-bootstrap/lib/bootstrap/component.rb', line 31

def append &block
  @append[-1] << block
end

#cardObject



39
40
41
# File 'card-mod-bootstrap/lib/bootstrap/component.rb', line 39

def card
  @context.context.card
end

#insert(&block) ⇒ Object



27
28
29
# File 'card-mod-bootstrap/lib/bootstrap/component.rb', line 27

def insert &block
  instance_exec(&block)
end

#prepend(&block) ⇒ Object



21
22
23
24
25
# File 'card-mod-bootstrap/lib/bootstrap/component.rb', line 21

def prepend &block
  tmp = @content.pop
  instance_exec(&block)
  @content << tmp
end

#renderObject



17
18
19
# File 'card-mod-bootstrap/lib/bootstrap/component.rb', line 17

def render
  @rendered = render_content
end

#wrap(tag = nil, &block) ⇒ Object



35
36
37
# File 'card-mod-bootstrap/lib/bootstrap/component.rb', line 35

def wrap tag=nil, &block
  @wrap[-1] << (block_given? ? block : tag)
end