public function getContent(string $name, array $data = []): string
    {
        $cacheName = $name;
        if ('' == $name) {
            $this->isRouteView = true;

            $stack = debug_backtrace();
            foreach ($stack as $item) {
                if (false !== stripos($item['file'], DIRECTORY_SEPARATOR . 'Route' . DIRECTORY_SEPARATOR)) {
                    $cacheName = pathinfo($item['file'], PATHINFO_DIRNAME) . '/' . $name;
                    $cacheName = explode('Route' . DIRECTORY_SEPARATOR, $cacheName)[1];
                    $cacheName = 'route_' . str_replace(['/', '\\'], '_', $cacheName);
                    break;
                }
            }
        }
        $cacheName .= '_' . $this->language . '.html.php';
        $path = $this->packageRoot . '/view/_cache/' . str_replace('/', '_', $cacheName);

        $exist = file_exists($path);
        if (!$this->cache || !$exist) {
            $code = $this->compile($name . '/view.html.php', true, true, true);

            $code = preg_replace(['/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s'], ['>', '<', '\\1'], $code);

            if ($exist) {
                $fh = fopen($path, 'r+b');
            } else {
                $fh = fopen($path, 'wb');
            }
            if (flock($fh, LOCK_EX)) {
                ftruncate($fh, 0);
                fwrite($fh, $code);
                flock($fh, LOCK_UN);
            }
            fclose($fh);
        }

        $fh = fopen($path, 'rb');
        if (flock($fh, LOCK_SH)) {
            $html = self::renderTemplate($path, $data);

            flock($fh, LOCK_UN);
            fclose($fh);

            return $html;
        }

        throw new \RuntimeException('Can\'t render template');
    }
public function getContent(string $name, array $data = []): string
    {
        $cacheName = $name;
        if ('' == $name) {
            $this->isRouteView = true;

            $stack = debug_backtrace();
            foreach ($stack as $item) {
                if (false !== stripos($item['file'], DIRECTORY_SEPARATOR . 'Route' . DIRECTORY_SEPARATOR)) {
                    $cacheName = pathinfo($item['file'], PATHINFO_DIRNAME) . '/' . $name;
                    $cacheName = explode('Route' . DIRECTORY_SEPARATOR, $cacheName)[1];
                    $cacheName = 'route_' . str_replace(['/', '\\'], '_', $cacheName);
                    break;
                }
            }
        }
        $cacheName .= '_' . $this->language . '.html.php';
        $path = $this->packageRoot . '/view/_cache/' . str_replace('/', '_', $cacheName);

        $exist = file_exists($path);
        if (!$this->cache || !$exist) {
            $code = $this->compile($name . '/view.html.php', true, true, true);

            $code = preg_replace(['/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s'], ['>', '<', '\\1'], $code);

            if ($exist) {
                $fh = fopen($path, 'r+b');
            } else {
                $fh = fopen($path, 'wb');
            }
            if (flock($fh, LOCK_EX)) {
                ftruncate($fh, 0);
                fwrite($fh, $code);
                flock($fh, LOCK_UN);
            }
            fclose($fh);
        }

        $fh = fopen($path, 'rb');
        if (flock($fh, LOCK_SH)) {
            $html = self::renderTemplate($path, $data);

            flock($fh, LOCK_UN);
            fclose($fh);

            return $html;
        }

        throw new \RuntimeException('Can\'t render template');
    }
public function getContent ( string $ name , array $ data = [ ] ) : string { $ cacheName = $ name ; if ( '' == $ name ) { $ this -> isRouteView = true ; $ stack = debug_backtrace ( ) ; foreach ( $ stack as $ item ) { if ( false !== stripos ( $ item [ 'file' ] , DIRECTORY_SEPARATOR . 'Route' . DIRECTORY_SEPARATOR ) ) { $ cacheName = pathinfo ( $ item [ 'file' ] , PATHINFO_DIRNAME ) . '/' . $ name ; $ cacheName = explode ( 'Route' . DIRECTORY_SEPARATOR , $ cacheName ) [ 1 ] ; $ cacheName = 'route_' . str_replace ( [ '/' , '\\' ] , '_' , $ cacheName ) ; break ; } } } $ cacheName .= '_' . $ this -> language . '.html.php' ; $ path = $ this -> packageRoot . '/view/_cache/' . str_replace ( '/' , '_' , $ cacheName ) ; $ exist = file_exists ( $ path ) ; if ( ! $ this -> cache || ! $ exist ) { $ code = $ this -> compile ( $ name . '/view.html.php' , true , true , true ) ; $ code = preg_replace ( [ '/\>[^\S ]+/s' , '/[^\S ]+\</s' , '/(\s)+/s' ] , [ '>' , '<' , '\\1' ] , $ code ) ; if ( $ exist ) { $ fh = fopen ( $ path , 'r+b' ) ; } else { $ fh = fopen ( $ path , 'wb' ) ; } if ( flock ( $ fh , LOCK_EX ) ) { ftruncate ( $ fh , 0 ) ; fwrite ( $ fh , $ code ) ; flock ( $ fh , LOCK_UN ) ; } fclose ( $ fh ) ; } $ fh = fopen ( $ path , 'rb' ) ; if ( flock ( $ fh , LOCK_SH ) ) { $ html = self :: renderTemplate ( $ path , $ data ) ; flock ( $ fh , LOCK_UN ) ; fclose ( $ fh ) ; return $ html ; } throw new \ RuntimeException ( 'Can\'t render template' ) ; }
Create content from template and data.

@param string $name
@param array $data
@return string
@throws FileNotFoundException
@throws \RuntimeException
Create content from template and data .