Phrozn\Site\View\Base::render PHP Method

render() public method

Render view
public render ( array $vars = [] ) : string
$vars array List of variables passed to text processors
return string
    public function render($vars = array())
    {
        // inject front matter options into template
        $vars = array_merge_recursive($vars, $this->getParams());
        // inject providers content
        if ($providers = $this->getParam('page.providers', false)) {
            $factory = new ProviderFactory();
            foreach ($providers as $varname => $data) {
                if (!isset($data['provider'])) {
                    continue;
                }
                $provider = $factory->create($data['provider'], $data);
                $provider->setProjectPath($this->getInputRootDir());
                $providedContent = $provider->get();
                $vars['page']['providers'][$varname] = $providedContent;
                $vars['this']['providers'][$varname] = $providedContent;
            }
        }
        // convert view into static representation
        $view = $this->getTemplate();
        foreach ($this->getProcessors() as $processor) {
            $view = $processor->render($view, $vars);
        }
        return $view;
    }

Usage Example

Example #1
0
 /**
  * Render view. Textile views are rendered within layout.
  *
  * @param array $vars List of variables passed to text processors
  *
  * @return string
  */
 public function render($vars = array())
 {
     $view = parent::render($vars);
     if ($this->hasLayout()) {
         // inject global site and front matter options into template
         $vars = array_merge($vars, $this->getParams());
         $view = $this->applyLayout($view, $vars);
     }
     return $view;
 }
All Usage Examples Of Phrozn\Site\View\Base::render