Class: ThemeCheck::HtmlNode
- Inherits:
-
Object
- Object
- ThemeCheck::HtmlNode
show all
- Extended by:
- Forwardable
- Includes:
- RegexHelpers
- Defined in:
- lib/theme_check/html_node.rb
Constant Summary
RegexHelpers::LIQUID_TAG, RegexHelpers::LIQUID_TAG_OR_VARIABLE, RegexHelpers::LIQUID_VARIABLE, RegexHelpers::START_OR_END_QUOTE
Instance Attribute Summary collapse
Instance Method Summary
collapse
#href_to_file_size, #matches
Constructor Details
#initialize(value, template, placeholder_values = [], parent = nil) ⇒ HtmlNode
Returns a new instance of HtmlNode.
10
11
12
13
14
15
|
# File 'lib/theme_check/html_node.rb', line 10
def initialize(value, template, placeholder_values = [], parent = nil)
@value = value
@template = template
@placeholder_values = placeholder_values
@parent = parent
end
|
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
8
9
10
|
# File 'lib/theme_check/html_node.rb', line 8
def parent
@parent
end
|
#template ⇒ Object
Returns the value of attribute template.
8
9
10
|
# File 'lib/theme_check/html_node.rb', line 8
def template
@template
end
|
Instance Method Details
#attributes ⇒ Object
31
32
33
34
35
|
# File 'lib/theme_check/html_node.rb', line 31
def attributes
@attributes ||= @value.attributes
.map { |k, v| [replace_placeholders(k), replace_placeholders(v.value)] }
.to_h
end
|
#children ⇒ Object
25
26
27
28
29
|
# File 'lib/theme_check/html_node.rb', line 25
def children
@children ||= @value
.children
.map { |child| HtmlNode.new(child, template, @placeholder_values, self) }
end
|
#content ⇒ Object
37
38
39
|
# File 'lib/theme_check/html_node.rb', line 37
def content
@content ||= replace_placeholders(@value.content)
end
|
#element? ⇒ Boolean
21
22
23
|
# File 'lib/theme_check/html_node.rb', line 21
def element?
@value.element?
end
|
#line_number ⇒ Object
63
64
65
|
# File 'lib/theme_check/html_node.rb', line 63
def line_number
@value.line
end
|
#literal? ⇒ Boolean
17
18
19
|
# File 'lib/theme_check/html_node.rb', line 17
def literal?
@value.name == "text"
end
|
#markup ⇒ Object
59
60
61
|
# File 'lib/theme_check/html_node.rb', line 59
def markup
@markup ||= replace_placeholders(@value.to_html)
end
|
#name ⇒ Object
51
52
53
54
55
56
57
|
# File 'lib/theme_check/html_node.rb', line 51
def name
if @value.name == "#document-fragment"
"document"
else
@value.name
end
end
|
#value ⇒ Object
placeholders for the HtmlNode to make sense.
43
44
45
46
47
48
49
|
# File 'lib/theme_check/html_node.rb', line 43
def value
if literal?
content
else
markup
end
end
|