Example #1
0
File: View.php Project: slince/view
 /**
  * (non-PHPdoc)
  *
  * @see \Slince\View\Engine\Native\ViewInterface::render()
  */
 function render($variables = [], $useLayout = true)
 {
     $viewRender = $this->_viewManager->getViewRender();
     $viewRender->set($variables);
     $content = '';
     if (!$viewRender->hasBlock('content')) {
         $content = $viewRender->render($this);
         $block = ViewFactory::createBlock($content);
         $viewRender->addBlock('content', $block);
     }
     if ($useLayout && !is_null($this->_layoutFile)) {
         $content = $viewRender->renderFile($this->_layoutFile);
     }
     $viewRender->reset();
     return $content;
 }
Example #2
0
 /**
  * 加载一个模板
  *
  * @param string $name
  * @return \Slince\View\View
  */
 function load($name, $layout = null)
 {
     $viewFile = $this->getViewFile($name);
     $layoutFile = empty($layout) ? null : $this->getLayoutFile($layout);
     return ViewFactory::createView($viewFile, $layoutFile, $this);
 }
Example #3
0
 /**
  * 捕捉一个视图块
  *
  * @param string $name
  */
 function start($name)
 {
     $this->_blocks[$name] = ViewFactory::createBlock();
     ob_start();
 }