Class: EsiForRack::Node::Try

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

#executeObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/esi_for_rack/node.rb', line 49

def execute
  unless @esi_attempt = node.css('esi_attempt')[0]
    raise "no attempt within try"
  end
  
  unless @esi_except = node.css('esi_except')[0]
    raise "no except within try"
  end
  
  val = ''
  begin
    context.process(@esi_attempt)
    @esi_attempt.inner_html
  rescue IncludeFailedError
    context.process(@esi_except)
    @esi_except.inner_html
  end
end