解析和获取模板内容

@param  string $template
@param  array $vars
@param  array $config
@param  bool $renderContent
@return string
771855
protected function fetch($template = '', $vars = [], $config = [], $renderContent = false)
    {
        $this->beforeViewRender();

        return $this->view->fetch($template, $vars, $config, $renderContent);
    }
239921
public function display($content, $vars = [], $replace = [], $config = [])
    {
        // 关闭模板布局
        $this->view->engine->layout(false);

        echo $this->view->display($content, $vars, $replace, $config);
    }
1087464
public function processTemplate($template, $vars = [])
    {
        // override the twig header vars for local resolution
        $this->grav->fireEvent('onTwigTemplateVariables');
        $vars += $this->twig_vars;

        try {
            $output = $this->twig->render($template, $vars);
        } catch (\Twig_Error_Loader $e) {
            throw new \RuntimeException($e->getRawMessage(), 404, $e);
        }

        return $output;

    }
527736
public function render(array $vars = array())
    {
        $templateFile = $this->getTemplateRouter()->findTemplateFile($this->getRequest());
        if ($templateFile) {
            return $this->getAppController()->render($templateFile, $vars);
        }
        return $this->getAppController()->error404();
    }
1259684
public function addTemplate($template, $vars = []) {
        $tpl = new Template($template, 'template-mail', 0);

        foreach ($vars as $key => $var) {
            $tpl->assign($key, $var);
        }

        $message = $tpl->show();
        array_push($this->_message, $message);
    }
186264
public function renderViewPrint( $template, $models, $config = [] ) {

		return $this->renderViewGeneric( $template, $models, CoreGlobal::TPL_VIEW_PRINT, $config );
	}
1040115
private function createCache($renderedContent)
    {
        if (!CmsComponent::isCmsLoggedIn()) {
            Cache::getInstance()->setCacheForPath(Request::$requestUri, $renderedContent, json_encode(ResponseHeaders::getHeaders()));
        }
    }
1267831
public function build($controller, array $vars = array())
    {
        $template = $this->mapManager->getUrlTemplateByController($controller);

        if ($template !== false) {
            if ($this->hasVar($template)) {
                return $this->prepare($controller, $template, $vars);
            } else {
                return $template;
            }

        } else {
            // Wrong controller, so nothing to return there
            return null;
        }
    }
503621
public function getTemplateContent(Template $template, $placeholders = [], $mode = 'content')
    {
        switch ($mode) {
            case 'content':
                return $this->replacePlaceholders($template->getContent(), $placeholders);
            case 'title':
                return $template->getTitle() ?
                    $this->replacePlaceholders($template->getTitle(), $placeholders) :
                    '';
        }

        return '';
    }
840682
async function _renderContent(uriPath) {
  const pathAnalyzer = new services.UriPathAnalyzer(uriPath, this.paths.www);
  const [file, pathSection, pathRecordId] = pathAnalyzer.perform();
  const content = {};

  if (!file) {
    throw Boom.notFound('Template not found');
  }

  const partials = glob.sync(resolve(this.paths.www, '**/_*.html'));
  const template = Template.fromFile(file, this.paths.www, partials, { parseConditionals: true });
  const tree = template.parse();

  /* eslint-disable no-restricted-syntax */
  for (const [token, args] of Object.entries(tree)) {
    const recordId = pathSection === args.name ? pathRecordId : null;
    /* eslint-disable-next-line no-await-in-loop */
    let recordContent = await Section.contentFor(args, recordId);

    if (this.config.placeholders) {
      recordContent = _addPlaceholders(recordContent, args);
    }

    content[token] = recordContent;
  }
  /* eslint-enable no-restricted-syntax */

  return template.render(content);
}
498579
protected function createDisplayResponse($template, array $variables)
    {
        return $this->getComponentResponseFactory()
            ->createComponentResponse()
                ->setContent(
                    new DisplayModel($template, $variables)
                );
    }
883784
protected function renderHtmlTemplateContent()
    {
        $config = $this->config();

        $factory = $this->templateFactory();
        $factory->setDefaultClass($config['default_controller']);

        $controller = $factory->create($config['controller']);
        $controller->init($this->httpRequest());
        $controller['app_handler'] = $this;
        $controller->setData($this->getTemplateData());

        foreach ($config['partials'] as $varName => $templateIdent) {
            $this->view()->setDynamicTemplate($varName, $templateIdent);
        }

        return $this->view()->render($config['template'], $controller);
    }
661795
protected function makeResponse(string $template, array $vars = [])
    {
        if (request()->ajax()) {
            return $this->jsonOutput($vars);
        }

        return $this->renderOutput($template, $vars);
    }
966555
protected static function getConfFromContents($contents, $filename = '(.yml)')
    {
        if (self::$params) {
            $template = new Template($contents, '%', '%');
            $template->setVars(self::$params);
            $contents = $template->produce();
        }

        try {
            return Yaml::parse($contents);
        } catch (ParseException $exception) {
            throw new ConfigurationException(
                sprintf(
                    "Error loading Yaml config from `%s`\n \n%s\nRead more about Yaml format https://goo.gl/9UPuEC",
                    $filename,
                    $exception->getMessage()
                )
            );
        }
    }
976172
function render(template, vars) {
    var rendered = template;

    for (var key in vars) {
        if (vars.hasOwnProperty(key)) {
            var val = vars[key];
            var regExpString = '\\{' + key + '\\}';
            var regExp = new RegExp(regExpString, 'g');

            rendered = rendered.replace(regExp, val);
        }
    }

    return rendered;
}
898833
protected function renderSimpleTemplate($templatePathAndFilename, array $contextVariables)
    {
        $content = file_get_contents($templatePathAndFilename);
        foreach ($contextVariables as $key => $value) {
            $content = str_replace('{' . $key . '}', $value, $content);
        }
        return $content;
    }
594112
public function renderView($viewVariables, $template)
    {
        $encoder = $this->handler->getEncoder();
        if (method_exists($encoder, 'renderView')) {
            return $encoder->renderView(
                $template,
                array_merge($this->viewContext, (array)$viewVariables)
            );
        } else {
            throw new Exception('The current encoder does not support the render view method.');
        }
    }