Return the rendered content of a template.
@param string $template
@param array $variables
@return string
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);
    }
1001852
public function renderTemplateString(string $template, array $variables = []): string
    {
        $output = $this->indexControlStructure($template, 'foreach');
        $output = $this->indexControlStructure($output, 'if', ['else']);

        $output = $this->resolveLoops($output, $variables);
        $output = $this->resolveConditionals($output, $variables);

        return $this->replaceVariablesInTemplate($output, $variables);
    }
1372952
public function getBlockFromTemplate($twig, $template, $block, $vars = [])
    {
        return $twig
            ->loadTemplate($template)
            ->renderBlock($block, $vars)
        ;
    }
156781
public function renderString($template, array $data = [])
    {
        return $this->executePlainRendering(
            trim($this->compiler->compile($template)),
            array_merge($data, ['__tintin' => $this])
        );
    }
738766
private function _renderTemplate($template, $vars)
	{
		extract($vars, EXTR_SKIP);
		ob_start();

		try
		{
			require($template);
			$contents = ob_get_contents();
		}
		catch (Exception $e)
		{
			// TODO: come up with a clever way of chaining exceptions
			ob_end_clean();
			throw $e;
		}

		ob_end_clean();
		return $contents;
	}
631363
public function render($template) {
		$environment = [
			'post' => $_POST,
			'get' => $_GET,
			'cookie' => $_COOKIE,
			'server' => $_SERVER,
		];

		$environment = array_merge($environment, $this->environment);

		if ($this->i18n_available === true and $this->translation !== null) {
			$environment['translation'] = $this->translation;
			$environment['language'] = $this->translation->language;
		}

		if (isset($_SESSION)) {
			$environment['session'] = $_SESSION;
		}
		$this->twig->setLoader($this->filesystem_loader);
		$this->twig->addGlobal('env', $environment);
		return $this->twig->render($template, $this->variables);
	}
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.');
        }
    }
777575
public function getMailRendered($template, array $variables = [], $type = MailTypes::TYPE_ALL)
    {
        $id = $this->getCacheId($template, $variables, $type);

        if (!isset($this->cache[$template][$id])) {
            $this->cache[$template][$id] = $this->getTemplater()->render($template, $variables, $type);
        }

        return $this->cache[$template][$id];
    }
486427
public function renderPage(string $template, array $data = []): string
    {
        $this->thisShouldMakeItUniqueCodeCollabTemplateHtmlVariables = $data;

        /** @noinspection PhpUnusedLocalVariableInspection */
        $content = $this->render($template, $data);

        try {
            ob_start();

            /** @noinspection PhpIncludeInspection */
            require $this->thisShouldMakeItUniqueCodeCollabTemplateHtmlBasePage;
        } finally {
            $output = ob_get_clean();
        }

        return $output;
    }
79325
public function renderHtml($template, array $variables = [], $type = MailTypes::TYPE_ALL)
    {
        return $this->getMailRendered($template, $variables, $type)->getHtmlBody();
    }
408242
protected function parseTemplate($variables = [], $template = null)
    {
        if (null === $template) $template = 'migration';
        $replacements = array_merge($variables, $this->templateVariables);
        return strtr(file_get_contents(dirname(__DIR__) . '/templates/' . $template . '.tpl'), $replacements);
    }
771855
protected function fetch($template = '', $vars = [], $config = [], $renderContent = false)
    {
        $this->beforeViewRender();

        return $this->view->fetch($template, $vars, $config, $renderContent);
    }
746594
protected function getRenderedReport($templateFilename = '', $variables = [])
    {
        $templatePath = 'EXT:solr/Resources/Private/Templates/Backend/Reports/' . $templateFilename;
        $standaloneView = $this->getFluidStandaloneViewWithTemplate($templatePath);
        $standaloneView->assignMultiple($variables);

        return $standaloneView->render();
    }
1292625
protected function getTemplate($template)
    {
        $source = __DIR__.'/../../templates/'.$template;
        return file_exists($source) ? file_get_contents($source) : null;
    }
1218960
protected function parseTemplate($template, array $vars = array())
    {
        if (strpos($template, '{') === false) {
            return $template;
        }

        if (preg_match_all('@\{\$([A-Za-z0-9_]+)\}@i', $template, $matches)) {
            foreach ($matches[1] as $varName) {
                $template = str_replace('{$' . $varName . '}', $vars[$varName], $template);
            }
        }

        return $template;
    }
492899
public function get($content, array $variables = [])
    {

        $replacements = [];
        $instruction  = 'foreach';

        foreach ($variables as $key => $values) {
            $inner = $this->getInnerInstruction($content, $instruction);
            foreach ($inner as $config) {
                if (!str_contains($config['cleared'], $key)) {
                    continue;
                }
                $replacements[$key] = $inner;
            }
        }
        if (!empty($replacements)) {
            foreach ($replacements as $key => $value) {
                foreach ($value as $element) {
                    $inner   = $this->renderByTwig($element['cleared'], $variables);
                    $content = str_replace(["[[{$instruction}]]", "[[/{$instruction}]]", $element['to_replace']], ['', '', $inner], $content);
                }
            }
        }

        $content = str_replace(['<p>', '</p>', '<br />'], '', $content);
        $filled  = $this->fill($content);

        preg_match_all('/\[\[(.*?)\]\]/', $content, $matches);

        if (!isset($matches[0]) or ! isset($matches[1])) {
            return $filled;
        }
        foreach ($matches[0] as $index => $variable) {
            $filled = str_replace($variable, '{{ ' . $matches[1][$index] . ' }}', $filled);
        }
        return $this->renderByTwig($filled, array_merge($variables, $this->variables));
    }
498579
protected function createDisplayResponse($template, array $variables)
    {
        return $this->getComponentResponseFactory()
            ->createComponentResponse()
                ->setContent(
                    new DisplayModel($template, $variables)
                );
    }