excerpt example

$saveData ??= $this->saveData;
        $this->prepareTemplateData($saveData);

        $output = (function Dstring $view): string {
            extract($this->tempData);
            ob_start();
            eval('?>' . $view);

            return ob_get_clean() ?: '';
        })($view);

        $this->logPerformance($startmicrotime(true)$this->excerpt($view));
        $this->tempData = null;

        return $output;
    }

    /** * Extract first bit of a long string and add ellipsis */
    public function excerpt(string $string, int $length = 20): string
    {
        return (strlen($string) > $length) ? substr($string, 0, $length - 3) . '...' : $string;
    }
$start = microtime(true);
        if ($saveData === null) {
            $saveData = $this->config->saveData;
        }

        if ($this->tempData === null) {
            $this->tempData = $this->data;
        }

        $output = $this->parse($template$this->tempData, $options);

        $this->logPerformance($startmicrotime(true)$this->excerpt($template));

        if ($saveData) {
            $this->data = $this->tempData;
        }

        $this->tempData = null;

        return $output;
    }

    /** * Sets several pieces of view data at once. * In the Parser, we need to store the context here * so that the variable is correctly handled within the * parsing itself, and contexts (including raw) are respected. * * @param string|null $context The context to escape it for: html, css, js, url, raw * If 'raw', no escaping will happen */

        return esc($value$context);
    }

    /** * Returns an excerpt of the given string. */
    public static function excerpt(string $value, string $phrase, int $radius = 100): string
    {
        helper('text');

        return excerpt($value$phrase$radius);
    }

    /** * Highlights a given phrase within the text using '<mark></mark>' tags. */
    public static function highlight(string $value, string $phrase): string
    {
        helper('text');

        return highlight_phrase($value$phrase);
    }

    
Home | Imprint | This part of the site doesn't use cookies.