Class: Lapillus::HtmlVisitor
Instance Attribute Summary collapse
-
#container_output ⇒ Object
INFO: there are 4 elements to remember INFO: 1 current template html element INFO: 2 current output html element INFO: 3 current component to render INFO: 4 current container to get components from.
-
#current_container ⇒ Object
Returns the value of attribute current_container.
Instance Method Summary collapse
-
#initialize(webpage) ⇒ HtmlVisitor
constructor
A new instance of HtmlVisitor.
- #visit_comment(comment) ⇒ Object
- #visit_element(element) ⇒ Object
- #visit_text(text) ⇒ Object
Constructor Details
#initialize(webpage) ⇒ HtmlVisitor
Returns a new instance of HtmlVisitor.
21 22 23 24 |
# File 'lib/lapillus/html_visitor.rb', line 21 def initialize(webpage) @container_output = REXML::Document.new @current_container = webpage end |
Instance Attribute Details
#container_output ⇒ Object
INFO: there are 4 elements to remember INFO: 1 current template html element INFO: 2 current output html element INFO: 3 current component to render INFO: 4 current container to get components from
18 19 20 |
# File 'lib/lapillus/html_visitor.rb', line 18 def container_output @container_output end |
#current_container ⇒ Object
Returns the value of attribute current_container.
19 20 21 |
# File 'lib/lapillus/html_visitor.rb', line 19 def current_container @current_container end |
Instance Method Details
#visit_comment(comment) ⇒ Object
41 42 43 44 |
# File 'lib/lapillus/html_visitor.rb', line 41 def visit_comment(comment) new_comment = REXML::Comment.new(comment) container_output.add(new_comment) end |
#visit_element(element) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/lapillus/html_visitor.rb', line 26 def visit_element(element) return if element.name=="fragment" #puts "rendering: #{element.name}" component_id = element.attributes['lapillus:id'] if !component_id.nil? child_component = current_container[component_id] else child_component = NullComponent.new end child_component.render_container(self, element) end |
#visit_text(text) ⇒ Object
38 39 40 |
# File 'lib/lapillus/html_visitor.rb', line 38 def visit_text(text) container_output.add_text(text.value) end |