Reputation: 51
I am generating static html pages using twig in a Symfony 4 project. Am trying to generate multiple pages at the same time with a simple loop and the Twig render function. Code looks like this:
foreach ($pages as $page) {
$html = $this->twig->render('template', $page);
$fileSystem->dumpFile('fileName', $html);
}
In the template am using, I load assets via webpack encore twig functions encore_entry_script_tags
and encore_entry_link_tags
.
The problem I face is that the assets are loaded for the first generated page but not the others ! The generated html content does not contain script and style tags.
I thought about possible Twig cache problem so I set the cache to false but that didn't solve the problem. Also, the problem is gone when I use the standard twig function {{ asset() }}
instead of webpack enore twig functions.
Any ideas ?!
Upvotes: 3
Views: 2476