Symfony webpack encore 树枝功能不起作用 [英] Symfony webpack encore twig functions not working
问题描述
我正在 Symfony 4 项目中使用 twig 生成静态 html 页面.我正在尝试使用一个简单的循环和 Twig 渲染函数同时生成多个页面.代码如下所示:
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);
}
在我使用的模板中,我通过 webpack encore twig 函数 encore_entry_script_tags
和 encore_entry_link_tags
加载资产.
In the template am using, I load assets via webpack encore twig functions encore_entry_script_tags
and encore_entry_link_tags
.
我面临的问题是,第一个生成的页面加载的资产,而不是其他页面!生成的 html 内容不包含 script 和 style 标签.
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.
我想到了可能的 Twig 缓存问题,所以我将缓存设置为 false,但这并没有解决问题.此外,当我使用标准的 twig 函数 {{ asset() }}
而不是 webpack enore twig 函数时,问题就消失了.
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.
有什么想法吗?!
推荐答案
问题已发现并已解决.查看此链接了解详情.这有点像一个错误",在我写这篇文章的时候团队还在努力.链接中提供了一种解决方法.
Problem found and solved. Check this link out for details. It's kinda a 'bug', the team still working on at the time I write this. A workaround is presented on the link.
这篇关于Symfony webpack encore 树枝功能不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!