Uncaught Twig\Error\SyntaxError: Unknown "template_from_string" function
chrisvidal opened this issue · comments
{{ include(template_from_string(copyright)) }}
or {% include template_from_string(copyright) %}
, from Timber documentation, results in the following error:
Uncaught Twig\Error\SyntaxError: Unknown "template_from_string" function
not sure if this is because of the theme, I would expect that a code from Timber doc. would work.
Did you ever figure out why it wasn't working? Im getting the same error.
The Twig template_from_string
function is not available by default. See the "Note" section in the link below.
https://twig.symfony.com/doc/3.x/functions/template_from_string.html
You can enable it in this theme by updating the existing add_to_twig
function in functions.php
with the following:
public function add_to_twig($twig)
{
$twig->addExtension(new \Twig\Extension\StringLoaderExtension());
return $twig;
}