Store Twig-templates in database

Hi Guys,

Last two days I am focussing how to use an database for storing .twig files (actually content). On the website there is an recipe but I don’t really get it.

Here is the link:

This is the ‘current’ syntax:

return $this->view->render($response, 'pages/page.twig', [
            'pageData'	=> $pageData

and I would like to replace ‘pages/page.twig’ for the array/data from the database. It does not work if I do it like this:

return $this->view->render($response, $template, [
            'pageData'	=> $pageData

How can I solve this?

Thanks in advance.

You probally need to use the template_from_string method:

Its what I use for templates stored in database.

Thanks SVL,

I will give it a try!