diff --git a/system/src/Grav/Common/Twig.php b/system/src/Grav/Common/Twig.php index 75d492846..d99bd275f 100644 --- a/system/src/Grav/Common/Twig.php +++ b/system/src/Grav/Common/Twig.php @@ -185,6 +185,24 @@ class Twig return $output; } + /** + * @param string $string string to render. + * @param array $vars Optional variables + * @return string + */ + public function processString($string, array $vars = array()) + { + // override the twig header vars for local resolution + $this->grav->fireEvent('onTwigStringVariables'); + $vars += $this->twig_vars; + + $name = '@Var:' . $string; + $this->setTemplate($name, $string); + $output = $this->twig->render($name, $vars); + + return $output; + } + /** * Twig process that renders the site layout. This is the main twig process that renders the overall * page and handles all the layout for the site display.