2 namespace TYPO3\CMS\Fluid\Core\ViewHelper;
63 $this->
registerArgument(
'then',
'mixed',
'Value to be returned if the condition if met.',
false);
64 $this->
registerArgument(
'else',
'mixed',
'Value to be returned if the condition if not met.',
false);
75 if (static::evaluateCondition($this->arguments)) {
93 $result = static::renderStaticThenChild($this->arguments, $hasEvaluated);
98 $elseViewHelperEncountered =
false;
99 foreach ($this->childNodes as $childNode) {
102 $data = $childNode->evaluate($this->renderingContext);
107 $elseViewHelperEncountered =
true;
111 if ($elseViewHelperEncountered) {
133 return $thenClosure();
138 $hasEvaluated =
false;
151 $hasEvaluated =
true;
152 $result = static::renderStaticElseChild($this->arguments, $hasEvaluated);
157 foreach ($this->childNodes as $childNode) {
160 return $childNode->evaluate($this->renderingContext);
183 return $elseClosure();
186 $hasEvaluated =
false;
201 public function compile($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode, \TYPO3\CMS\
Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode, \TYPO3\CMS\
Fluid\Core\Compiler\TemplateCompiler $templateCompiler)
203 foreach ($syntaxTreeNode->getChildNodes() as $childNode) {
206 $childNodesAsClosure = $templateCompiler->wrapChildNodesInClosure($childNode);
207 $initializationPhpCode .= sprintf(
'%s[\'__thenClosure\'] = %s;', $argumentsVariableName, $childNodesAsClosure) . LF;
211 $childNodesAsClosure = $templateCompiler->wrapChildNodesInClosure($childNode);
212 $initializationPhpCode .= sprintf(
'%s[\'__elseClosure\'] = %s;', $argumentsVariableName, $childNodesAsClosure) . LF;
216 return sprintf(
'%s::renderStatic(%s, %s, $renderingContext)',
217 get_class($this), $argumentsVariableName, $renderChildrenClosureVariableName);
232 $hasEvaluated =
true;
233 if (static::evaluateCondition($arguments)) {
234 $result = static::renderStaticThenChild($arguments, $hasEvaluated);
241 $result = static::renderStaticElseChild($arguments, $hasEvaluated);