Class: Garterbelt::ContentTag
Instance Attribute Summary
Attributes inherited from ClosedTag
#attributes, #css_class, #type
Attributes inherited from Renderer
#escape, #style, #view
Instance Method Summary
collapse
included
Methods inherited from ClosedTag
#render, #rendered_attributes, #template
Methods inherited from Renderer
#indent, #level, #line_end, #output, #output=, #render
Constructor Details
#initialize(opts, &block) ⇒ ContentTag
Returns a new instance of ContentTag.
5
6
7
8
9
10
11
12
|
# File 'lib/renderers/content_tag.rb', line 5
def initialize(opts, &block)
super
if block_given?
self.content = block
else
self.content = opts[:content]
end
end
|
Instance Method Details
#c(*classes, &block) ⇒ Object
20
21
22
23
24
|
# File 'lib/renderers/content_tag.rb', line 20
def c(*classes, &block)
super(*classes)
self.content = block if block_given?
self
end
|
49
50
51
52
|
# File 'lib/renderers/content_tag.rb', line 49
def
super
self.output <<
end
|
40
41
42
43
44
45
46
47
|
# File 'lib/renderers/content_tag.rb', line 40
def
if style == :text
[:p, :ul, :ol, :li].include?(type) ? "\n" : ''
else
= style == :compact ? '' : indent
"#{}</#{type}>#{line_end}"
end
end
|
#head ⇒ Object
35
36
37
38
|
# File 'lib/renderers/content_tag.rb', line 35
def head
self.output << head_template
super
end
|
#head_template ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/renderers/content_tag.rb', line 26
def head_template
if style == :text
''
else
head_end = style == :compact ? '' : line_end
"#{indent}<#{type}#{rendered_attributes}>#{head_end}"
end
end
|
#id(identifier, &block) ⇒ Object
14
15
16
17
18
|
# File 'lib/renderers/content_tag.rb', line 14
def id(identifier, &block)
super(identifier)
self.content = block if block_given?
self
end
|