[FEATURE] Add DotsToBracketsViewHelper

This commit is contained in:
Philipp Dieter 2021-06-09 15:13:40 +02:00
parent 5a435098dd
commit 0109796bc6

View File

@ -0,0 +1,21 @@
<?php
namespace Cjel\TemplatesAide\ViewHelpers;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
class DotsToBracketsViewHelper extends AbstractViewHelper
{
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
) {
$parts = explode('.', $renderChildrenClosure());
$_ = '[\'';
$_ .= implode('\'][\'', $parts);
$_ .= '\']';
return $_;
}
}