@param $template
@param $vars

@throws \Exception
@throws \Throwable

@return string
348712
public function renderTemplate($template, $vars)
    {
        $twig = $this->getContainer()->get('twig');

        $template = $twig->createTemplate($template);

        return $template->render($vars);
    }
1193711
private static function template($t, $vars = array())
    {
        $t = preg_replace_callback('/\s+|<[^>]++>/', array('self', 'templateCb'), $t);
        array_unshift($vars, $t);
        $code = call_user_func_array('sprintf', $vars);
        return $code;
    }
307590
protected function renderOutput(string $template, array $vars = [])
    {
        $vars = array_merge($vars, [
            'unpublished' => Article::select(['id', 'user_id', 'state'])
            ->when('owner' != user('role'), function ($query) {
                // Show unpublished articles only to current user.
                $query->where('user_id', user('id'));
            })
            ->where('state', '<>', 'published')
            ->get(),
        ]);

        return parent::renderOutput($template, $vars);
    }
381105
protected function setServicesFile($path, $template, array $vars) {
    $this->addServicesFile()
      ->path($path)
      ->template($template)
      ->vars($vars);
  }
905679
public function render($template, array $locals = [])
    {
        foreach ($this->engines as $engine) {
            if ($engine->supports($template)) {
                return $engine->render($template, $locals);
            }
        }

        throw new Exception("Unable to find template [{$template}]");
    }
830559
public function getTemplateFile($template)
    {
        $paths  = $this->config["path"];
        $suffix = $this->config["suffix"];

        foreach ($paths as $path) {
            $file = $path . "/" . $template . $suffix;
            if (is_file($file)) {
                return $file;
            }
        }

        throw new Exception("Could not find template file '$template'.");
    }
65663
public function fetch($template, $vars = [], $config = [])
    {
        if ($vars) {
            $this->data = $vars;
        }

        if ($config) {
            $this->config($config);
        }

        $template = $this->parseTemplateFile($template);

        if ($template) {

            $cacheFile = $this->config['cache_path'] . $this->config['cache_prefix'] . md5($this->config['layout_on'] . $this->config['layout_name'] . $template) . '.' . ltrim($this->config['cache_suffix'], '.');

            if (!$this->checkCache($cacheFile)) {
                // 缓存无效 重新模板编译
                $content = file_get_contents($template);
                $this->compiler($content, $cacheFile);
            }

            // 页面缓存
            ob_start();
            ob_implicit_flush(0);

            // 读取编译存储
            $this->storage->read($cacheFile, $this->data);

            // 获取并清空缓存
            $content = ob_get_clean();

            echo $content;
        }
    }
771855
protected function fetch($template = '', $vars = [], $config = [], $renderContent = false)
    {
        $this->beforeViewRender();

        return $this->view->fetch($template, $vars, $config, $renderContent);
    }
992665
protected function renderOutput(string $template, array $vars = [])
    {
        $tpl = $this->template . '.'. $template;

        if (view()->exists($tpl)) {
            return view($tpl, $vars)->render();
        }

        abort(404, "View named $tpl not exists.");
    }
1033950
protected function render(string $template, array $vars = [])
    {
        $vars['flash'] = $this->flash;
        $this->view->setVars($vars);

        $content = $this->view->render($template);
        $this->response->setContent($content);

        return $this->response;
    }
971246
protected function loadTemplate( $path, array $vars = [] ) {

		$search = '/templates/epub201/';
		$replace = '/templates/epub3/';

		$pos = strpos( $path, $search );
		if ( false !== $pos ) {
			$new_path = substr_replace( $path, $replace, $pos, strlen( $search ) );
			if ( file_exists( $new_path ) ) {
				$path = $new_path;
			}
		}

		return parent::loadTemplate( $path, $vars );
	}
351458
public function getTemplateContent($template, array $variables)
    {
        $dir = dirname($template);
        $file = basename($template);

        $twig = new \Twig_Environment(new \Twig_Loader_Filesystem(array($dir)), array(
            'debug'            => true,
            'cache'            => false,
            'strict_variables' => true,
            'autoescape'       => false,
        ));
        return $twig->render($file, $variables);
    }
523578
public function render($template, $variables, $default = false)
    {
        if ($default) {
            $template = $this->homeService->defaultTemplate($template);
        }

        return new Response($this->templating->render($template, $variables));
    }
934664
public function render($template, array $vars = array(), $cookies = array(), $domain = null)
    {
        $vars['__menu__'] = $this->getMenu();
        if(Config::getParam('profiling.enable')) {
            $vars['__profiling__'] = Inspector::getStats();
        }
        $domain = (null === $domain) ? $this->getDomain() : $domain;
        return $this->tpl->render($domain . $template, $vars, $cookies);
    }
599333
protected function formatTemplate($template, array $vars)
    {
        $output = $template;
        $token = $this->buildToken();

        foreach ($vars as $key => $value) {
            $replacement = sprintf($token, $key);

            if (!$this->isFlagEnabled(self::ALLOW_NEWLINES)) {
                $value = $this->sanitizeNewlines($value);
            }

            if (false !== strpos($output, $replacement)) {
                $output = str_replace($replacement, $value, $output);
            }
        }

        $output = $this->removeExtraTokens($token, $output);

        return $output;
    }
411537
protected function expandTemplate($template, array $variables = null)
    {
        $expansionVars = $this->getConfig()->toArray();
        if ($variables) {
            $expansionVars = $variables + $expansionVars;
        }

        return $this->getUriTemplate()->expand($template, $expansionVars);
    }
1284807
public function addTemplateVars(array $vars)
    {
        foreach($vars as $key => $value)
        {
            $this->addTemplateVar($key, $value);
        }

        return $this;

    }