Class: Arbo::HTML::TextNode
Instance Attribute Summary
Attributes inherited from Element
#arbo_context, #children, #parent
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Element
#+, #<<, #ancestors, #assigns, #children?, #content, #content=, #each, #find_first_ancestor, #get_elements_by_class_name, #get_elements_by_tag_name, #helpers, #html_safe, #indent_level, #initialize, #inspect, #parent?, #remove_child, #render_in_or_to_s, #to_ary, #to_str
#build_tag, #current_arbo_element, included, #insert_tag, #with_current_arbo_element
Constructor Details
This class inherits a constructor from Arbo::Element
Class Method Details
.from_string(string) ⇒ Object
Builds a text node from a string
11
12
13
14
15
|
# File 'lib/arbo/html/text_node.rb', line 11
def self.from_string(string)
node = new
node.build(string)
node
end
|
Instance Method Details
#add_child(*args) ⇒ Object
17
18
19
|
# File 'lib/arbo/html/text_node.rb', line 17
def add_child(*args)
raise "TextNodes do not have children"
end
|
#build(string) ⇒ Object
21
22
23
|
# File 'lib/arbo/html/text_node.rb', line 21
def build(string)
@content = string
end
|
#class_list ⇒ Object
25
26
27
|
# File 'lib/arbo/html/text_node.rb', line 25
def class_list
[]
end
|
#render_in(context) ⇒ Object
37
38
39
|
# File 'lib/arbo/html/text_node.rb', line 37
def render_in(context)
to_s.tap { |s| context.output_buffer << s }
end
|
#tag_name ⇒ Object
29
30
31
|
# File 'lib/arbo/html/text_node.rb', line 29
def tag_name
nil
end
|
#to_s ⇒ Object
33
34
35
|
# File 'lib/arbo/html/text_node.rb', line 33
def to_s
ERB::Util.html_escape(@content.to_s)
end
|