public function protectCDataSectionsFromParser($templateSource)
    {
        $parts = preg_split('/(\<\!\[CDATA\[|\]\]\>)/', $templateSource, -1, PREG_SPLIT_DELIM_CAPTURE);
        $balance = 0;
        $content = '';
        $resultingParts = [];
        foreach ($parts as $index => $part) {
            unset($parts[$index]);

            if ($balance === 0 && $part === '<![CDATA[') {
                $balance++;
                continue;
            }

            if ($balance === 0) {
                $resultingParts[] = $part;
                continue;
            }

            if ($balance === 1 && $part === ']]>') {
                $balance--;
            }

            if ($balance > 0 && $part === '<![CDATA[') {
                $balance++;
            }

            if ($balance > 0 && $part === ']]>') {
                $balance--;
            }

            if ($balance > 0) {
                $content .= $part;
            }

            if ($balance === 0 && $content !== '') {
                $resultingParts[] = '<f:format.base64Decode>' . base64_encode($content) . '</f:format.base64Decode>';
                $content = '';
            }
        }

        return implode('', $resultingParts);
    }
public function protectCDataSectionsFromParser($templateSource)
    {
        $parts = preg_split('/(\<\!\[CDATA\[|\]\]\>)/', $templateSource, -1, PREG_SPLIT_DELIM_CAPTURE);
        $balance = 0;
        $content = '';
        $resultingParts = [];
        foreach ($parts as $index => $part) {
            unset($parts[$index]);

            if ($balance === 0 && $part === '<![CDATA[') {
                $balance++;
                continue;
            }

            if ($balance === 0) {
                $resultingParts[] = $part;
                continue;
            }

            if ($balance === 1 && $part === ']]>') {
                $balance--;
            }

            if ($balance > 0 && $part === '<![CDATA[') {
                $balance++;
            }

            if ($balance > 0 && $part === ']]>') {
                $balance--;
            }

            if ($balance > 0) {
                $content .= $part;
            }

            if ($balance === 0 && $content !== '') {
                $resultingParts[] = '<f:format.base64Decode>' . base64_encode($content) . '</f:format.base64Decode>';
                $content = '';
            }
        }

        return implode('', $resultingParts);
    }
public function protectCDataSectionsFromParser ( $ templateSource ) { $ parts = preg_split ( '/(\<\!\[CDATA\[|\]\]\>)/' , $ templateSource , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; $ balance = 0 ; $ content = '' ; $ resultingParts = [ ] ; foreach ( $ parts as $ index => $ part ) { unset ( $ parts [ $ index ] ) ; if ( $ balance === 0 && $ part === '<![CDATA[' ) { $ balance ++ ; continue ; } if ( $ balance === 0 ) { $ resultingParts [ ] = $ part ; continue ; } if ( $ balance === 1 && $ part === ']]>' ) { $ balance -- ; } if ( $ balance > 0 && $ part === '<![CDATA[' ) { $ balance ++ ; } if ( $ balance > 0 && $ part === ']]>' ) { $ balance -- ; } if ( $ balance > 0 ) { $ content .= $ part ; } if ( $ balance === 0 && $ content !== '' ) { $ resultingParts [ ] = '<f:format.base64Decode>' . base64_encode ( $ content ) . '</f:format.base64Decode>' ; $ content = '' ; } } return implode ( '' , $ resultingParts ) ; }
Encodes areas enclosed in CDATA to prevent further parsing by the Fluid engine.
CDATA sections will appear as they are in the final rendered result.

@param string $templateSource
@return mixed
Encodes areas enclosed in CDATA to prevent further parsing by the Fluid engine . CDATA sections will appear as they are in the final rendered result .