@param Template $template
@param array    $placeholders
@param string   $mode

@return string
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 '';
    }
689121
public static function template(
        $template,
        $parameters,
        $startChar = '%',
        $endChar = '%'
    ) {
        foreach ($parameters as $key => $value) {
            $template = str_replace($startChar . $key . $endChar, $value, $template);
        }
        return $template;
    }
1140289
public function render(string $location, string $template = 'platform::partials.mainMenu'): string
    {
        $this->checkAccess();

        return $this->findAllChildren($location)
            ->sortBy('sort')
            ->map(function ($value) use ($template) {
                return view($template, $value)->render();
            })
            ->implode(' ');
    }
1289129
public function getChunk($path, array $placeholders = [])
    {
        $template = clone $this;
        $template->scopes[spl_object_hash($this)] = $this;
        $template->removeAllPlaceholders();
        list($cacheKey, $cacheExpire, $cacheTags) = $template->calculateCacheParams($placeholders);
        // Get cache
        if (($resultCache = $template->getCacheContent($cacheKey)) !== false) {
            return $resultCache;
        }
        $result = $template->renderInternal($path, $placeholders);
        // Set cache
        $template->setCacheContent($cacheKey, $result, $cacheExpire, $cacheTags ?: []);

        return $result;
    }
370889
public static function compileTemplate(&$context, $template) {
        array_unshift($context['parsed'], array());
        Validator::verify($context, $template);
        static::$lastParsed = $context['parsed'];

        if (count($context['error'])) {
            return;
        }

        Parser::setDelimiter($context);

        $context['compile'] = true;

        // Handle dynamic partials
        Partial::handleDynamic($context);

        // Do PHP code generation.
        $code = '';
        foreach ($context['parsed'][0] as $info) {
            if (is_array($info)) {
                $context['tokens']['current']++;
                $code .= "'" . static::compileToken($context, $info) . "'";
            } else {
                $code .= $info;
            }
        }

        array_shift($context['parsed']);

        return $code;
    }
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);
    }
612953
protected function format($message, array $placeholders = [])
    {
        foreach ($placeholders as $name => $value) {
            $placeholders[":$name"] = $value;
            unset($placeholders[$name]);
        }
        
        return strtr($message, $placeholders);
    }
191454
public function SQLTemplate($mode)
    {
        $this->mode = $mode;
        $this->template = $this->sql_templates[$mode];

        return $this;
    }
544273
public static function transform(array &$target, array $placeholders)
    {
        $wrap = function (string & $value) {
            $value = sprintf('/%s/', $value);
        };
        array_walk_recursive($target, function (&$param) use ($wrap, $placeholders) {
            if (!\is_string($param)) { return; }
            if (preg_match('/^const\((.*)\)$/', $param, $matches)) {
                $param = \constant($matches[1]);
            } elseif (preg_match_all('/%(.+?)%/', $param, $matches)) {
                array_walk($matches[0], $wrap);
                $pattern = $matches[0];
                $replacement = array_intersect_key($placeholders, array_flip($matches[1]));
                $param = preg_replace($pattern, $replacement, $param);
            }
        });
    }
132738
public static function getQueryTemplate($template, ...$arguments)
    {
        $strQuery = $template;
        foreach ($arguments as $i => &$argument) {
            $strQuery = str_replace('%' . $i, $argument, $strQuery);
        }

        return $strQuery;
    }
22986
public static function parseTemplate($template, $data, $keepPlaceholders = false)
    {
        $t = $template;

        $hasMatches = preg_match_all("/[{]([^}]+)[}]/", $t, $matches);

        if ($hasMatches) {
            foreach ($matches[ 0 ] as $key => $match) {
                if (isset($data[$matches[1][$key]])) {
                    $template = str_replace($match, $data[$matches[1][$key]], $template);
                } else if (!$keepPlaceholders) {
                    $template = str_replace($match, '', $template);
                }
            }
        }

        return $template;
    }
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;

    }
320946
protected function render($templateName, array $placeholderValuePairs)
    {
        $resultString = Messages::get($templateName);
        foreach ($placeholderValuePairs as $placeholder => $value) {
            $resultString = str_replace('{{ '.$placeholder.' }}', $value, $resultString);
        }

        return $resultString;
    }
893287
protected function resolveLoops($template, $variables): string
    {
        return preg_replace_callback(
            '/\{%\s*foreach(?<index>-[\d]+-[\d]+-)\s+' . self::REGEX_VARIABLE . '\s+as\s+(?<scopeVar>[a-z0-9]+)\s*%\}' .
                '(?<body>.+)' .
            '\{%\s*endforeach\k<index>\s*%\}/si',
            function (array $matches) use ($variables): string {
                $output = '';

                foreach ($this->getValue($matches, $variables) as $value) {
                    $scope = array_merge($variables, [$matches['scopeVar'] => $value]);

                    $output .= $this->replaceVariablesInTemplate(
                        $this->resolveConditionals(
                            $this->resolveLoops($matches['body'], $scope),
                            $scope
                        ),
                        $scope
                    );
                }
                return $output;
            },
            $template
        );
    }
1100559
public static function renderTemplate($template, $replacements){
		foreach ($replacements as $find => $replace) {
			$template = \str_replace($find, $replace, $template);
		}
		return $template;
	}
48726
public function parse(string $template, array $replacements = []): string
    {
        $paragraph = Paragraph::make($template, $replacements);

        return $paragraph->parse([$this, 'decorate']);
    }
1238439
public static function view($template, $vars, $context = 'core')
    {
        // Display template
        echo self::getInstance()->twig->render('@'.$context.'/'.$template, $vars);
    }