Renders a story.

@param array $paths
@param array $data
503194
protected function _render($story, $paths, $data)
    {
        settype($paths, 'array');

        foreach ($paths as $path) {
            if ($this->_template->findFile($path)) {
                return $this->_template->loadFile($path, $data)->render();
            }
        }

        try {
            return $this->_template->loadTemplate($story->name, $data)->render();
        } catch (Exception $e) {
            print '<small>file missing :'.$path.'</small>';
        }
    }
292053
public function set($path, array $data)
    {
        $data += array('path' => $path);

        $bookmark = $this->get($data);
        return empty($bookmark) ? (bool) $this->add($data) : false;
    }
7468
public function render(array $data = [])
    {
        $this->data($data);
        unset($data);
        extract($this->data);

        if (! $this->exists()) {
            throw new LogicException(
                'The template "'.$this->name->getName().'" could not be found at "'.$this->path().'".'
            );
        }

        try {
            $level = ob_get_level();
            ob_start();

            include $this->path();

            $content = ob_get_clean();

            if (isset($this->layoutName)) {
                $layout = $this->engine->make($this->layoutName);
                $layout->setFile($this->file);
                $layout->sections = array_merge($this->sections, ['content' => $content]);
                $content = $layout->render($this->layoutData);
            }

            return $content;
        } catch (Throwable $e) {
            while (ob_get_level() > $level) {
                ob_end_clean();
            }

            throw $e;
        } catch (Exception $e) {
            while (ob_get_level() > $level) {
                ob_end_clean();
            }

            throw $e;
        }
    }
407463
public function renderView($path, $data)
    {
        $obLevel = ob_get_level();
        ob_start();
        extract($data);

        /*
         | We will try to include view file and check content into try catch block
         | so that if any exception occurs output buffer will get flush out.
        */
        try {
            include $path;
        } catch (Exception $e) {
            $this->handleViewException($e, $obLevel);
        }

        return ltrim(ob_get_clean());
    }
1292720
public function display(array $data = null): void
    {
        if ($this->fileHead != null) {
            $this->load($this->fileHead, $data);
        }

        $this->load($this->file, $data); // main file

        if ($this->fileFoot != null) {
            $this->load($this->fileFoot, $data);
        }
    }
410359
protected function doPost($path, array $params = null, array $data = null)
    {
        return $this->getResult('POST', $path, $params, $data);
    }
852270
public function renderTree(array $data)
    {
        $helper = Mage::helper('aoe_profiler'); /* @var $helper Aoe_Profiler_Helper_Data */

        $output = '';
        foreach ($data as $key => $uniqueId) {
            if (strpos($key, '_children') === false) {

                $tmp = $this->stackLog[$uniqueId];

                $hasChildren = isset($data[$key . '_children']) && count($data[$key . '_children']) > 0;

                $duration = round($tmp['time_total'] * 1000);
                $output .= '<li duration="' . $duration . '" class="' . ($tmp['level'] > 1 ? 'collapsed' : '') . ' level-' . $tmp['level'] . ' ' . ($hasChildren ? 'has-children' : '') . '">';

                $output .= '<div class="info">';

                $output .= '<div class="profiler-label">';
                if ($hasChildren) {
                    $output .= '<div class="toggle profiler-open">&nbsp;</div>';
                    $output .= '<div class="toggle profiler-closed">&nbsp;</div>';
                }

                $label = end($tmp['stack']);

                if (isset($tmp['detail'])) {
                    $label .= ' (' . htmlspecialchars($tmp['detail']) . ')';
                }

                $type = Varien_Profiler::getType($tmp['type'], $label);


                $output .= '<span class="caption type-' . $type . '" title="' . htmlspecialchars($label) . '" />';

                if (isset($tmp['file'])) {
                    $remoteCallUrlTemplate = Mage::getStoreConfig('dev/debug/remoteCallUrlTemplate');
                    $linkTemplate = '<a href="%s" onclick="var ajax = new XMLHttpRequest(); ajax.open(\'GET\', this.href); ajax.send(null); return false">%s</a>';
                    $url = sprintf($remoteCallUrlTemplate, $tmp['file'], intval($tmp['line']));
                    $output .= sprintf($linkTemplate, $url, htmlspecialchars($label));
                } else {
                    $output .= htmlspecialchars($label);
                }

                $output .= '</span>';

                $output .= '</div>'; // class="label"

                $output .= '<div class="profiler-columns">';
                foreach ($this->metrics as $metric) {
                    $formatterMethod = 'format_' . $metric;
                    $ownTitle = 'Own: ' . $helper->$formatterMethod($tmp[$metric . '_own']) . ' '
                        . $this->units[$metric] . ' / ' . round($tmp[$metric . '_rel_own'] * 100, 2) . '%';
                    $subTitle = 'Sub: ' . $helper->$formatterMethod($tmp[$metric . '_sub']) . ' '
                        . $this->units[$metric] . ' / ' . round($tmp[$metric . '_rel_sub'] * 100, 2) . '%';
                    $totalTitle = $helper->$formatterMethod($tmp[$metric . '_own'] + $tmp[$metric . '_sub']) . ' '
                        . $this->units[$metric] . ' / '
                        . round(($tmp[$metric . '_rel_own'] + $tmp[$metric . '_rel_sub']) * 100, 2) . '%';
                    $fullTitle = $totalTitle . ' (' . $ownTitle . ', ' . $subTitle . ')';

                    $output .= '<div class="metric" title="' . $fullTitle . '">';

                    $progressBar = $this->renderProgressBar(
                        $tmp[$metric . '_rel_own'] * 100,
                        $tmp[$metric . '_rel_sub'] * 100,
                        $tmp[$metric . '_rel_offset'] * 100
                    );
                    $output .= '<div class="' . $metric . ' profiler-column">' . $progressBar . '</div>';

                    $output .= '</div>'; // class="metric"

                }
                $output .= '</div>'; // class="profiler-columns"

                $output .= '</div>'; // class="info"

                if ($hasChildren) {
                    $output .= '<ul>' . $this->renderTree($data[$key . '_children']) . '</ul>';
                }

                $output .= '</li>';
            }
        }
        return $output;
    }
82701
public function renderLayout(array $data = null)
    {
        !$data or extract($data);
        ob_start();

        /** @noinspection PhpIncludeInspection */
        if (file_exists(rtrim(
                $this->getLayoutPath(), $this->getFileExt()
            ) . $this->getFileExt())) {

            include rtrim(
                    $this->getLayoutPath(), $this->getFileExt()
                ) . $this->getFileExt();

        } elseif (file_exists(rtrim(
                $this->getLayoutFallbackPath(), $this->getFileExt()
            ) . $this->getFileExt())) {

            include rtrim(
                    $this->getLayoutFallbackPath(), $this->getFileExt()
                ) . $this->getFileExt();
        } else {

            throw new ViewNotFoundException('View ' . rtrim(
                    $this->getLayoutPath(), $this->getFileExt()
                ) . $this->getFileExt() . ' not found');
        }

        $rendered = ob_get_contents();
        ob_end_clean();

        return $rendered;
    }
269310
public function putContents($path, $data, $flags = 0)
    {
        $fullPath = $this->concatPaths($path); //todo remove after changing the params

        if ($this->checkCreateFile($fullPath) === false) {
            throw new Error('Permission denied for '. $fullPath);
        }

        $res = (file_put_contents($fullPath, $data, $flags) !== FALSE);
        if ($res && function_exists('opcache_invalidate')) {
            @opcache_invalidate($fullPath);
        }

        return $res;
    }
755588
public function compile(string $path, array $data = [])
    {
        // If the file can't be found it's probably supplied as a template within
        // one of the base directories
        $path = $this->find($path);

        // Make sure that we use the right resolver for the initial file
        $engine = $this->factory->getEngineFromPath($path);

        // this path needs to be string
        return $view = new View(
            $this->factory,
            $engine,
            $path, // view (not sure what it does)
            $path,
            $data
        );
    }
842454
public function writeData(array $data, array $lengths)
    {
        foreach ($data as $row) {
            $rowOutput = $this->table_headerPart;

            foreach ($row as $key => $value) {
                $rowOutput .= ' '.str_pad($value, $lengths[$key], ' ', STR_PAD_RIGHT).' '.$this->table_headerPart;
            }

            $this->output->writeln($rowOutput);
        }
    }
197478
public function renderView($viewPath, array $data = null)
    {
        $this->setView($viewPath);

        !$data or extract($data);
        ob_start();

        if (file_exists(rtrim(
                $this->getViewPath(), $this->getFileExt()
            ) . $this->getFileExt())) {

            /** @noinspection PhpIncludeInspection */
            include rtrim(
                    $this->getViewPath(), $this->getFileExt()
                ) . $this->getFileExt();

        } elseif (file_exists(rtrim(
                $this->getViewFallbackPath(), $this->getFileExt()
            ) . $this->getFileExt())) {

            /** @noinspection PhpIncludeInspection */
            include rtrim(
                    $this->getViewFallbackPath(), $this->getFileExt()
                ) . $this->getFileExt();

        } else {
            throw new ViewNotFoundException('View ' . rtrim(
                    $this->getViewPath(), $this->getFileExt()
                ) . $this->getFileExt() . ' not found');
        }

        $rendered = ob_get_contents();
        ob_end_clean();

        return $rendered;
    }
445987
private function writeData($data, $files)
    {
        // Initialise:
        
        $result = true;
        
        // Check Parameters:
        
        if (is_array($data) && is_array($files)) {
            
            // Iterate Files:
            
            foreach ($files as $file) {
                
                // Attempt to Process File:
                
                try {
                    
                    // Read File Contents:
                    
                    $contents = file_get_contents($file);
                    
                    // Replace Tokens in Contents:
                    
                    $contents = $this->replace($contents, $data);
                    
                    // Write File Contents:
                    
                    file_put_contents($file, $contents);
                    
                    // Define Status:
                    
                    $status = 'success';
                    
                } catch (ErrorException $e) {
                    
                    // Write Debug Info:
                    
                    $this->io()->writeError(
                        sprintf(
                            '<warning>Exception: %s</warning>',
                            $e->getMessage()
                        ),
                        true,
                        IOInterface::DEBUG
                    );
                    
                    // Define Result:
                    
                    $result = false;
                    
                    // Define Status:
                    
                    $status = 'failure';
                    
                }
                
                // Output Status:
                
                $this->io()->write(
                    sprintf(
                        '[%s] %s',
                        $this->color($this->getConfig("text-file-{$status}"), $this->getConfig("fg-{$status}")),
                        $this->color("Writing to '{$file}'...", $this->getConfig('fg-writing'))
                    )
                );
                
            }
            
        }
        
        // Answer Result:
        
        return $result;
    }
107545
public function render(array $data = [])
	{
		// run the methods
		$this->before();

		if (method_exists($this, $this->method))
		{
			$this->{$this->method}();
		}

		$this->after();

		// transfer the presenter data to the view
		$this->view->merge($this);

		// set autofilter on view
		$this->view->autoFilter($this->autoFilter);

		// render the view
		return $this->view->render($data);
	}
225253
private function writeFile($path, $data)
    {
        if (false === @file_put_contents($path, $data)) {
            throw new DumperException(sprintf('Unable to write file "%s"', $path));
        }
    }
372473
public function preloadEmbeddedNodes(
        array $messages,
        array $paths = [],
        string $namespace = NcrPreloader::DEFAULT_NAMESPACE
    ): void {
        $this->ncrPreloader->addEmbeddedNodeRefs($messages, $paths, $namespace);
    }
478244
protected function read($data, array $paths)
    {
        $result = new AppendIterator();

        foreach ($paths as $path) {
            if (is_array($path)) {
                $result->append(new ArrayIterator($this->readArray($data, $path)));
            } else {
                $result->append(new ArrayIterator([$this->readString($data, $path)]));
            }
        }

        return $result;
    }