Class: Arbre::HTML::TextNode

Inherits:
Element show all
Defined in:
lib/active_admin/arbre/text_node.rb

Constant Summary

Constants included from Arbre::HTML

AUTO_BUILD_ELEMENTS, HTML5_ELEMENTS

Instance Attribute Summary

Attributes inherited from Element

#children, #parent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Element

#+, #<<, #assigns, builder_method, #content, #content=, #document, #each, #get_elements_by_tag_name, #helpers, #html_safe, #indent_level, #initialize, #parent?, #remove_child, #to_ary, #to_s, #to_str

Methods included from BuilderMethods

#build_tag, #current_dom_context, #insert_tag, #insert_text_node_if_string, #with_current_dom_context

Methods included from Arbre::HTML

#current_dom_context, #helpers, #method_missing

Constructor Details

This class inherits a constructor from Arbre::HTML::Element

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Arbre::HTML

Class Method Details

.from_string(string) ⇒ Object

Builds a text node from a string



11
12
13
14
15
# File 'lib/active_admin/arbre/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/active_admin/arbre/text_node.rb', line 17

def add_child(*args)
  raise "TextNodes do not have children"
end

#build(string) ⇒ Object



21
22
23
# File 'lib/active_admin/arbre/text_node.rb', line 21

def build(string)
  @content = string
end

#tag_nameObject



25
26
27
# File 'lib/active_admin/arbre/text_node.rb', line 25

def tag_name
  nil
end

#to_htmlObject



29
30
31
# File 'lib/active_admin/arbre/text_node.rb', line 29

def to_html
  ERB::Util.html_escape(@content.to_html)
end