通过模板引擎响应输出HTML

@param array $data 待渲染KV数据
@param string|null $view 文件名
@throws \Exception
@throws \Throwable
@throws Exception
973596
public function outputView(array $data, $view = null)
    {
        if ($this->controller->requestType !== Macro::HTTP_REQUEST) {
            throw new Exception('$this->outputView not support '. $this->controller->requestType);
        }

        $this->setContentType('text/html; charset=UTF-8');
        if (empty($view)) {
            $view = str_replace('\\', '/', $this->getContext()->getControllerName()) . '/' .
                str_replace($this->getConfig()->get('http.method_prefix', 'action'), '', $this->getContext()->getActionName());
        }

        $responseBody = null;
        $found = false;
        $engine = getInstance()->templateEngine;
        $viewResolvePaths = getInstance()->viewResolvePaths;

        foreach ($viewResolvePaths as $basePath) {
            $template = $engine->setDirectory($basePath)->make($view);
            if (!$template->exists()) {
                continue;
            }
            $responseBody = $template->render($data);
            $found = true;
            break;
        }
        if (!$found) {
            throw new Exception(sprintf('A template named %s was not found in any folder, please check again', $view));
        }
        $this->end($responseBody);
    }
740310
public function setView($view, array $data = [])
    {
        $this->view = $view;

        $this->data = $data;

        return $this;
    }
367294
public function render($view, $data = [], $mergeData = [])
    {
        if ($this->request()->ajax() && $this->request()->wantsJson()) {
            return app()->call([$this, 'ajax']);
        }

        if ($action = $this->request()->get('action') and in_array($action, $this->actions)) {
            if ($action == 'print') {
                return app()->call([$this, 'printPreview']);
            }

            return app()->call([$this, $action]);
        }

        return view($view, $data, $mergeData)->with($this->dataTableVariable, $this->getHtmlBuilder());
    }
1141797
protected function setTextBody($view, array $data)
    {
        $this->message->builder()->setTextBody($this->renderView($view, $data));
    }
56057
public function renderViewElement(View $view): ?string
    {
        if (empty($this->viewElement)) {
            return null;
        }

        return call_user_func_array([$view, 'element'], $this->viewElement);
    }
1190254
public function render($data = [], $view = null)
    {
        $view = $view ? : MenuManager::PLUGIN_NAME . '::master_menu';

        return $this->manager->getView()->make($view, ['menu' => $this], $data)
            ->render();
    }
259011
public function make($view, $data = [])
    {
        try {
            return $this->view->make($view, $data)->render();
        } catch (\InvalidArgumentException $e) {
            throw new ViewNotFoundException("No file found at '{$view}'");
        }
    }
979764
protected function view($view, $data = [])
    {
        return parent::view($view, $data)
            ->with('settings', settings())
            ->with('banners', $this->getBanners())
            ->with('popularPages', $this->popularPages)
            ->with('showPageBanner', $this->showPageBanner)
            ->with('activePageTiers', $this->activePageTiers)
            ->with('footerNavigation', $this->footerNavigation)
            ->with('navigationFeatured', $this->navigationFeatured);
    }
1137141
public static function get($view, $data = array()){

        if( $data ){
            self::$level = self::$level + 1;
            self::$data[ self::$level ] = (array) $data;
        }

        $file = SRC. "{$view}.php";

        // Parse view
        ob_start();

            self::process($file);

            if( $data ){

                unset(self::$data[ self::$level ]);
                self::$level = self::$level - 1;
                self::process(NULL);

            }

            $view = ob_get_contents();

        ob_end_clean();

        return $view;
    }
795009
public function render($view, $values = array())
    {
        // Setup the template path
        $folder = $this->app->config('templates.path');
        $view = $folder . $view . '.php';

        // Check if the template exists
        if (!file_exists($view)) {
            throw new \Exception('Template not found: ' . $view, 404);
        }

        // Extract values and include template
        extract($values);
        ob_start();
        include $view;
        $html = ob_get_contents();
        ob_end_clean();

        // Return rendered HTML
        return $html;
    }
16748
public static function addView(string $view, array $data): void
    {
        if (self::$debugbar instanceof StandardDebugBar) {
            $collector = self::$debugbar->getCollector('views');

            if ($collector instanceof ViewCollector) {
                $collector->addView($view, $data);
            }
        }
    }
933167
public function renderEach($view, $data, $iterator, $empty = 'raw|')
    {
        $result = '';

        // If is actually data in the array, we will loop through the data and append
        // an instance of the partial view to the final result HTML passing in the
        // iterated value of this data array, allowing the views to access them.
        if (count($data) > 0) {
            foreach ($data as $key => $value) {
                $result .= $this->make(
                    $view, ['key' => $key, $iterator => $value]
                )->render();
            }
        }

        // If there is no data in the array, we will render the contents of the empty
        // view. Alternatively, the "empty view" could be a raw string that begins
        // with "raw|" for convenience and to let this know that it is a string.
        else {
            $result = Str::startsWith($empty, 'raw|')
                        ? substr($empty, 4)
                        : $this->make($empty)->render();
        }

        return $result;
    }
1089828
protected function render($view, array $data = [])
    {
        // Extract variables.
        extract($data);

        // Start buffering.
        ob_start();

        // Load view file (root location is declared in viewPath var).
        include $this->container->get('config')['viewsPath'] . '/' . $view . '.php';

        // Get buffered content
        $body = ob_get_contents();
        ob_end_clean();

        // Make response and add body to it
        $response = new Response();
        $response->writeBody($body);
        return $response;
    }
572221
private function render(string $view, $data = []) : Mail
  {
    $body = array(
      'body' => $this->body,
      'subject' => $this->subject
    );

    if ($this->body != null) {
      $data = array_merge($data, $body);
    }

    $this->outputdata = View::make($this->viewLocation, $data, true);
    return $this;
  }
287155
public function output($view, array $data = null)
	{
		$response = new Response($this->render($view, $data), Response::HTTP_OK, ['Content-Type' => 'text/html']);
		$response->send();
	}
80503
public function render($view, array $data = [], $conditions = [])
    {
        // view parts
        $file = strtok($view, '/');
        $section = strtok('/');

        // Get Body-Template
        $template = $this->getTemplate($file);

        // extend with default data
        $data += $this->data;

        // set tags
        foreach ($data as $name => $value) {
            $template->addText($name, $value);
        }
        foreach ($conditions as $name => $value) {
            $template->addCond($name, $value);
        }

        // Render Page
        return $template->get($section);
    }
256708
public function render($view = null, $data = array())
    {
        if (is_null($view)) {
            $view = static::$defaultSimpleView;
        }

        $data = array_merge($data, array(
            'paginator' => $this,
        ));

        return new HtmlString(
            static::viewFactory()->make($view, $data)->render()
        );
    }