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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/esi_for_rack/node.rb', line 72
def execute
whens = node.css('esi_when').to_a
raise "no when's within choose" 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.inner_html
end
end
if otherwise
context.process(otherwise)
return otherwise.inner_html
end
nil
end
|