17 use TYPO3Fluid\Fluid\Core\Exception;
18 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
19 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
20 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
75 use CompileWithRenderStatic;
114 $this->registerArgument(
'value',
'string',
'The input value. If not given, the evaluated child nodes will be used.',
false,
null);
115 $this->registerArgument(
'mode',
'string',
'The case to apply, must be one of this\' CASE_* constants. Defaults to uppercase application.',
false, self::CASE_UPPER);
127 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
129 $value = $arguments[
'value'];
130 $mode = $arguments[
'mode'];
132 if ($value ===
null) {
133 $value = $renderChildrenClosure();
138 $output = mb_strtolower($value,
'utf-8');
141 $output = mb_strtoupper($value,
'utf-8');
144 $firstChar = mb_substr($value, 0, 1,
'utf-8');
145 $firstChar = mb_strtoupper($firstChar,
'utf-8');
146 $remainder = mb_substr($value, 1,
null,
'utf-8');
150 $firstChar = mb_substr($value, 0, 1,
'utf-8');
151 $firstChar = mb_strtolower($firstChar,
'utf-8');
152 $remainder = mb_substr($value, 1,
null,
'utf-8');
156 $output = mb_convert_case($value, MB_CASE_TITLE,
'utf-8');
159 throw new Exception(
'The case mode "' . $mode .
'" supplied to Fluid\'s format.case ViewHelper is not supported.', 1358349150);