Class: Card::Bootstrap::TagMethod
- Inherits:
-
Object
- Object
- Card::Bootstrap::TagMethod
show all
- Includes:
- Content
- Defined in:
- mod/bootstrap/lib/card/bootstrap/tag_method.rb
Overview
support html tag generation
Instance Method Summary
collapse
Constructor Details
#initialize(component, name, html_class, tag_opts = {}, &tag_block) ⇒ TagMethod
Returns a new instance of TagMethod.
7
8
9
10
11
12
13
14
15
16
|
# File 'mod/bootstrap/lib/card/bootstrap/tag_method.rb', line 7
def initialize component, name, html_class, tag_opts={}, &tag_block
@component = component
@name = name
@html_class = html_class
@tag_opts = tag_opts
@tag_block = tag_block
@append = []
@wrap = []
@xm = Builder::XmlMarkup.new
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
27
28
29
30
31
|
# File 'mod/bootstrap/lib/card/bootstrap/tag_method.rb', line 27
def method_missing method, *args, &block
return super unless respond_to_missing? method
@component.send method, *args, &block
end
|
Instance Method Details
#append(&block) ⇒ Object
47
48
49
|
# File 'mod/bootstrap/lib/card/bootstrap/tag_method.rb', line 47
def append &block
@append[-1] << block
end
|
#call(*_args, &content_block) ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'mod/bootstrap/lib/card/bootstrap/tag_method.rb', line 18
def call *_args, &content_block
component.content.push "".html_safe
opts = process_content(&content_block)
process_collected_content tag_name, opts
process_append
""
end
|
#prepend(&block) ⇒ Object
37
38
39
40
41
|
# File 'mod/bootstrap/lib/card/bootstrap/tag_method.rb', line 37
def prepend &block
tmp = @content.pop
instance_exec(&block)
@content << tmp
end
|
#respond_to_missing?(method, _include_private = false) ⇒ Boolean
33
34
35
|
# File 'mod/bootstrap/lib/card/bootstrap/tag_method.rb', line 33
def respond_to_missing? method, _include_private=false
@component.respond_to? method
end
|
#wrap(&block) ⇒ Object
43
44
45
|
# File 'mod/bootstrap/lib/card/bootstrap/tag_method.rb', line 43
def wrap &block
instance_exec(&block)
end
|
#wrapInner(tag = nil, &block) ⇒ Object
51
52
53
|
# File 'mod/bootstrap/lib/card/bootstrap/tag_method.rb', line 51
def wrapInner tag=nil, &block
@wrap[-1] << (block_given? ? block : tag)
end
|