Class: EsiForRack::Node::Include

Inherits:
EsiForRack::Node show all
Defined in:
lib/esi_for_rack/node.rb

Constant Summary

Constants inherited from EsiForRack::Node

IncludeFailedError

Instance Attribute Summary

Attributes inherited from EsiForRack::Node

#context, #node

Instance Method Summary collapse

Methods inherited from EsiForRack::Node

#execute_in_place!, #init

Instance Method Details

#continue_on_error?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/esi_for_rack/node.rb', line 29

def continue_on_error?
  node['onerror'] == 'continue'
end

#executeObject



33
34
35
36
37
# File 'lib/esi_for_rack/node.rb', line 33

def execute
  context.lookup(resolved_src) or
  (resolved_alt && context.lookup(resolved_alt)) or
  (!continue_on_error? && raise(IncludeFailedError.new)) or nil
end

#resolved_altObject



25
26
27
# File 'lib/esi_for_rack/node.rb', line 25

def resolved_alt
  EsiAttributeLanguage::SimpleGrammar.parse(@node['alt']).execute(context.resolver) if @node['alt']
end

#resolved_srcObject



21
22
23
# File 'lib/esi_for_rack/node.rb', line 21

def resolved_src
  EsiAttributeLanguage::SimpleGrammar.parse(@node['src']).execute(context.resolver)
end