渲染一个视图模板, 并直接输出给请求端

@param string $tpl
@param array $tpl_vars

@return bool
@throws \Exception
496289
public function display($tpl, $tpl_vars = null) {
        if (!($this->_response instanceof \Swoole\Http\Response)) {
            throw new \Exception(200118);
        }


        $old_value = ini_set('xdebug.cli_color', 0);
        $html = $this->render($tpl, $tpl_vars);
        $this->_response->end($html);
        $old_value === false || ini_set('xdebug.cli_color', $old_value);
        return true;
    }
727842
protected function render($tpl = null, array $data = []) {
        if ($this instanceof Controller) {
            if (is_array($tpl)) {
                $data = $tpl;
                $tpl  = null;
            }
            $layout = '~' . $this->layout;
            $data   = $this->onInitLayoutData($data);
            if ($tpl && $tpl{0} == '~') {
                $tpl = substr($tpl, 1);
                $tpl = $this->realPath($tpl . '.tpl');
            } else if ($tpl) {
                $path = str_replace(['\\', 'controllers'], [DS, 'views'], $this->reflectionObj->getNamespaceName());
                $tpl  = $this->realPath($path . DS . $tpl . '.tpl');
            } else {
                $path = str_replace(['\\', 'controllers'], [DS, 'views'], $this->reflectionObj->getNamespaceName());
                $tpl  = $this->realPath($path . DS . $this->ctrName . DS . $this->action . '.tpl');
            }
            $data['workspaceView'] = $tpl;
            $view                  = view($layout, $data);

            return $view;
        }

        return null;
    }
892476
public function display($tpl = '')
    {
        $tpl || $tpl = Url::pathInfo();

        if($this->layout){
            self::$content = $this->_getContent($tpl);
            $content = $this->_getContent($this->layout);
        }else
            $content = $this->_getContent($tpl);
        $this->addToken($content);
        headers_sent() || header('Content-Type: text/html; charset=utf-8');
        echo $content;
    }
1297234
public function display($tpl = '')
    {
        if (Container::get('request')->isCli()) {
            throw new ResponseException('cannot render template in CLI mode');
        }

        if ('' === $tpl) {
            $tpl = Container::get('route')->getController() . '/'
            . Container::get('route')->getAction();
        }

        $this->viewPath = $this->tplDir . $tpl . '.html';
        if (!Helper::isFile($this->viewPath)) {
            throw new NotFoundException('Template is not existed.');
        }

        unset($tpl);
        ob_start();
        extract($this->data, EXTR_OVERWRITE);
        include $this->viewPath;
        $buffer = ob_get_contents();
        ob_get_clean();
        $output = Helper::comment() . preg_replace('|</body>.*?</html>|is', '', $buffer, -1, $count) . Container::get('trace')->showTrace();
        if ($count > 0) {
            $output .= '</body></html>';
        }

        echo $output;
    }
604781
public static function show404Page($tpl = null)
    {
        self::sendHttpStatus(404);
        is_null($tpl) && $tpl = Config::get('404_page');
        is_file($tpl) && Cml::requireFile($tpl);
        exit();
    }
790570
public function display($tpl = null)
	{
		$this->form = $this->get('Form');
		$this->item = $this->get('Item');
		$this->state = $this->get('State');
		$section = $this->state->get('category.section') ? $this->state->get('category.section') . '.' : '';
		$this->canDo = JHelperContent::getActions($this->state->get('category.component'), $section . 'category', $this->item->id);
		$this->assoc = $this->get('Assoc');

		// Check for errors.
		if (count($errors = $this->get('Errors')))
		{
			JError::raiseError(500, implode("\n", $errors));

			return false;
		}

		JFactory::getApplication()->input->set('hidemainmenu', true);

		if ($this->getLayout() == 'modal')
		{
			$this->form->setFieldAttribute('language', 'readonly', 'true');
			$this->form->setFieldAttribute('parent_id', 'readonly', 'true');
		}

		$this->addToolbar();

		return parent::display($tpl);
	}
1181029
public static function display($tpl, $variablesDefinitions = NULL, $indent = NULL) {
    $html = self::get($tpl, $variablesDefinitions, $indent);
    print $html;
  }
1169165
protected function fetchReply($rpl)
    {
        foreach ($rpl as $key => $val) {
            if ($val->startsWith(Teamspeak::GREET)) {
                unset($rpl[$key]);
            } elseif ($val->startsWith(Teamspeak::EVENT)) {
                $this->evt[] = new Event($rpl[$key], $this->con);
                unset($rpl[$key]);
            }
        }

        $this->rpl = new StringHelper(implode(Teamspeak::SEPARATOR_LIST, $rpl));
    }
663297
public function createLocalArrayVariable($tpl_var, $nocache = false, $scope = Smarty::SCOPE_LOCAL)
    {
        if (!isset($this->tpl_vars[$tpl_var])) {
            $this->tpl_vars[$tpl_var] = new Smarty_variable(array(), $nocache, $scope);
        } else {
            $this->tpl_vars[$tpl_var] = clone $this->tpl_vars[$tpl_var];
            if ($scope != Smarty::SCOPE_LOCAL) {
                $this->tpl_vars[$tpl_var]->scope = $scope;
            }
            if (!(is_array($this->tpl_vars[$tpl_var]->value) || $this->tpl_vars[$tpl_var]->value instanceof ArrayAccess)) {
                settype($this->tpl_vars[$tpl_var]->value, 'array');
            }
        }
    }
767603
public function dump_vars($vars)
    {
        $this->last_selector = null;
        $args = array();
        foreach (func_get_args() as $index => $func) {
            if ($func instanceof PheryResponse || $func instanceof PheryFunction) {
                $args[$index] = array($this->typecast($func, true, true));
            } elseif (is_object($func)) {
                $args[$index] = array(get_object_vars($func));
            } else {
                $args[$index] = array($func);
            }
        }

        return $this->cmd(6, $args);
    }
425750
function process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace )
    {
        $params = $functionParameters;
        $loop = null;
        if ( isset( $params["loop"] ) )
        {
            $loop = $tpl->elementValue( $params["loop"], $rootNamespace, $currentNamespace, $functionPlacement );
        }
        if ( $loop !== null and !is_array( $loop ) )
        {
            $tpl->error( $functionName, "Can only loop arrays", $functionPlacement );
            return;
        }

        $name = "";
        if ( !isset( $params["name"] ) )
        {
            $tpl->missingParameter( $functionName, "name" );
            return;
        }
        $name = $tpl->elementValue( $params["name"], $rootNamespace, $currentNamespace, $functionPlacement );
        $seq_var =& $GLOBALS["eZTemplateSequence-$name"];
        if ( !is_array( $seq_var ) )
            $seq_var = array();
        if ( $loop !== null )
        {
            $seq_var["loop"] = $loop;
            $seq_var["iteration"] = 0;
            $seq_var["index"] = 0;
        }
        else
        {
            $index =& $seq_var["index"];
            $iteration =& $seq_var["iteration"];
            ++$iteration;
            ++$index;
            if ( $index >= count( $seq_var["loop"] ) )
                $index = 0 ;
        }
        $tpl->setVariable( "item", $seq_var["loop"][$seq_var["index"]], $tpl->mergeNamespace( $rootNamespace, $name ) );
        $tpl->setVariable( "iteration", $seq_var["iteration"], $tpl->mergeNamespace( $rootNamespace, $name ) );
    }
1182926
public function tpl(string $tpl, ?array $params = [], ?string $dir = null)
    {
        try {
            $this->message = App::$View->render($tpl, $params, $dir);
        } catch (SyntaxException $e) {
        }
        return $this;
    }
1295090
function append($tpl_var, $value=null, $merge=false)
	{
		if (is_array($tpl_var)) {
			// $tpl_var is an array, ignore $value
			foreach ($tpl_var as $_key => $_val) {
				if ($_key != '') {
					if(!@is_array($this->_tpl_vars[$_key])) {
						settype($this->_tpl_vars[$_key],'array');
					}
					if($merge && is_array($_val)) {
						foreach($_val as $_mkey => $_mval) {
							$this->_tpl_vars[$_key][$_mkey] = $_mval;
						}
					} else {
						$this->_tpl_vars[$_key][] = $_val;
					}
				}
			}
		} else {
			if ($tpl_var != '' && isset($value)) {
				if(!@is_array($this->_tpl_vars[$tpl_var])) {
					settype($this->_tpl_vars[$tpl_var],'array');
				}
				if($merge && is_array($value)) {
					foreach($value as $_mkey => $_mval) {
						$this->_tpl_vars[$tpl_var][$_mkey] = $_mval;
					}
				} else {
					$this->_tpl_vars[$tpl_var][] = $value;
				}
			}
		}
	}
655052
public function getOutput($tpl = null)
	{
	    $output = $this->fetch($tpl);
        if ($this->isError($output)) {
            $text = $this->__config['error_text'];
            return $this->escape($text);
        } else {
            return $output;
        }
	}
1206467
public function render($tpl,  $tpl_vars = null) {
        $tpl_vars && $this->assign($tpl_vars);
        return $this->_process($tpl);
    }
645110
public function dump(\Twig_Environment $env, $context, ...$vars)
    {
        if (!$env->isDebug()) {
            return null;
        }

        if (!$vars) {
            $vars = [];
            foreach ($context as $key => $value) {
                if (!$value instanceof \Twig_Template) {
                    $vars[$key] = $value;
                }
            }
        }

        ob_start();

        VarDumper::dump($vars);

        echo ob_get_clean();
    }
1290730
public function display($tpl = null)
	{
		$this->state         = $this->get('State');
		$this->items         = $this->get('Items');
		$this->pagination    = $this->get('Pagination');
		$this->assoc         = $this->get('Assoc');
		$this->filterForm    = $this->get('FilterForm');
		$this->activeFilters = $this->get('ActiveFilters');

		// Check for errors.
		if (count($errors = $this->get('Errors')))
		{
			JError::raiseError(500, implode("\n", $errors));

			return false;
		}

		// Preprocess the list of items to find ordering divisions.
		foreach ($this->items as &$item)
		{
			$this->ordering[$item->parent_id][] = $item->id;
		}

		// Levels filter - Used in Hathor.
		$this->f_levels = array(
			JHtml::_('select.option', '1', JText::_('J1')),
			JHtml::_('select.option', '2', JText::_('J2')),
			JHtml::_('select.option', '3', JText::_('J3')),
			JHtml::_('select.option', '4', JText::_('J4')),
			JHtml::_('select.option', '5', JText::_('J5')),
			JHtml::_('select.option', '6', JText::_('J6')),
			JHtml::_('select.option', '7', JText::_('J7')),
			JHtml::_('select.option', '8', JText::_('J8')),
			JHtml::_('select.option', '9', JText::_('J9')),
			JHtml::_('select.option', '10', JText::_('J10')),
		);

		// We don't need toolbar in the modal window.
		if ($this->getLayout() !== 'modal')
		{
			$this->addToolbar();
			$this->sidebar = JHtmlSidebar::render();
		}
		else
		{
			// In article associations modal we need to remove language filter if forcing a language.
			if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'CMD'))
			{
				// If the language is forced we can't allow to select the language, so transform the language selector filter into an hidden field.
				$languageXml = new SimpleXMLElement('<field name="language" type="hidden" default="' . $forcedLanguage . '" />');
				$this->filterForm->setField($languageXml, 'filter', true);

				// Also, unset the active language filter so the search tools is not open by default with this filter.
				unset($this->activeFilters['language']);
			}
		}

		return parent::display($tpl);
	}