Class: EsiForRack::Node::Context
- Inherits:
-
Object
- Object
- EsiForRack::Node::Context
- Defined in:
- lib/esi_for_rack/node.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#lookup ⇒ Object
readonly
Returns the value of attribute lookup.
-
#resolver ⇒ Object
readonly
Returns the value of attribute resolver.
Instance Method Summary collapse
-
#initialize(resolver, lookup) ⇒ Context
constructor
A new instance of Context.
- #parse(document) ⇒ Object
- #process(doc_fragment) ⇒ Object
Constructor Details
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
87 88 89 |
# File 'lib/esi_for_rack/node.rb', line 87 def doc @doc end |
#lookup ⇒ Object (readonly)
Returns the value of attribute lookup.
87 88 89 |
# File 'lib/esi_for_rack/node.rb', line 87 def lookup @lookup end |
#resolver ⇒ Object (readonly)
Returns the value of attribute resolver.
87 88 89 |
# File 'lib/esi_for_rack/node.rb', line 87 def resolver @resolver end |
Instance Method Details
#parse(document) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/esi_for_rack/node.rb', line 100 def parse(document) document.gsub!('esi:', 'esi_') @doc = Nokogiri::HTML(document) @doc.css('esi_comment').each do |esi_comment| esi_comment.replace(Nokogiri::XML::CDATA.new(doc, '')) end process(@doc) @doc end |
#process(doc_fragment) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/esi_for_rack/node.rb', line 114 def process(doc_fragment) # have to go one at a time because of limitation of .css, its not a live list. while esi_node = doc_fragment.css('esi_try,esi_choose,esi_vars,esi_include')[0] case esi_node.name.to_sym when :esi_include @include.init(esi_node, self).execute_in_place! when :esi_choose @choose.init(esi_node, self).execute_in_place! when :esi_vars @vars.init(esi_node, self).execute_in_place! when :esi_try @try.init(esi_node, self).execute_in_place! end end end |