private function escapeTemplate($value) {
        $result = $value;

        $result = str_replace('{{', chr(1), $result);
        $result = str_replace('}}', chr(2), $result);

        $result = preg_replace_callback('/([^\{\/\x5c]+|)(\{[^\}]+\})([^\{\/\x5c]+|)/', function($m) {
            array_shift($m);

            $m = array_filter($m, function($item) {
                return !empty($item);
            });

            $m = array_map(function($item) {
                return mb_substr($item, 0, 1) !== '{' ? preg_quote($item, '/') : $item;
            }, $m);

            return implode('', $m);
        }, $result);

        $result = str_replace(chr(1), '\\{', $result);
        $result = str_replace(chr(2), '\\}', $result);

        return $result;
    }
private function escapeTemplate($value) {
        $result = $value;

        $result = str_replace('{{', chr(1), $result);
        $result = str_replace('}}', chr(2), $result);

        $result = preg_replace_callback('/([^\{\/\x5c]+|)(\{[^\}]+\})([^\{\/\x5c]+|)/', function($m) {
            array_shift($m);

            $m = array_filter($m, function($item) {
                return !empty($item);
            });

            $m = array_map(function($item) {
                return mb_substr($item, 0, 1) !== '{' ? preg_quote($item, '/') : $item;
            }, $m);

            return implode('', $m);
        }, $result);

        $result = str_replace(chr(1), '\\{', $result);
        $result = str_replace(chr(2), '\\}', $result);

        return $result;
    }
private function escapeTemplate ( $ value ) { $ result = $ value ; $ result = str_replace ( '{{' , chr ( 1 ) , $ result ) ; $ result = str_replace ( '}}' , chr ( 2 ) , $ result ) ; $ result = preg_replace_callback ( '/([^\{\/\x5c]+|)(\{[^\}]+\})([^\{\/\x5c]+|)/' , function ( $ m ) { array_shift ( $ m ) ; $ m = array_filter ( $ m , function ( $ item ) { return ! empty ( $ item ) ; } ) ; $ m = array_map ( function ( $ item ) { return mb_substr ( $ item , 0 , 1 ) !== '{' ? preg_quote ( $ item , '/' ) : $ item ; } , $ m ) ; return implode ( '' , $ m ) ; } , $ result ) ; $ result = str_replace ( chr ( 1 ) , '\\{' , $ result ) ; $ result = str_replace ( chr ( 2 ) , '\\}' , $ result ) ; return $ result ; }
Quote regular expression characters.

@return string
Quote regular expression characters .