Hello,
so far I have this code
if (class_exists('\Twig\Environment') && is_readable($sAddonThemePath.'/groups.twig'))
{
// create twig template object
$loader = new \Twig\Loader\FilesystemLoader($sAddonThemePath);
$twig = new \Twig\Environment($loader, [
'autoescape' => false,
'cache' => false,
'strict_variables' => false,
'debug' => false,
'auto_reload' => true,
]);
$aJsonRespond['out'] = $twig->render('groups.twig', $aTplData);
} else {
// Twig not exists
$aJsonRespond['out'] = '<br>TWIG is not initialized!';
}
I am wondering is there a possibility that instead
$aJsonRespond['out'] = $twig->render('groups.twig', $aTplData);
I use
$groups_twig = ' .... '; / content of groups.twig file stored in database
$aJsonRespond['out'] = $twig->render($groups_twig, $aTplData);
So far we have modules with header/ loop/ footer that are using placeholders , but only as str_replace(vars, values , setting_field) , and twig is much more advanced.
So is there possibility to use php variable instead of file, so that template can be editable in backend ?