Class: EsiForRack::Node::Choose
Constant Summary
IncludeFailedError
Instance Attribute Summary
#context, #node
Instance Method Summary
collapse
#execute_in_place!, #init
Instance Method Details
#execute ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/esi_for_rack/node.rb', line 70
def execute
whens = node.css('esi_when').to_a
raise "choose block contains no when elements" if whens.empty?
otherwise = node.css('esi_otherwise')[0]
whens.each do |esi_when|
if EsiAttributeLanguage::Grammar.parse(esi_when['test']).execute(context.resolver).equal?(true)
context.process(esi_when)
return esi_when.to_str
end
end
if otherwise
context.process(otherwise)
return otherwise.to_str
end
nil
end
|