我需要在我的页面上呈现/显示HTML文件。这些HTML文件需要由某人上传,然后呈现。
实际上,我这样做。 (book.htmlsrc
是我文件的名称)
{{ source('book/html/' ~ book.htmlsrc)}}
但我需要在我的app / ressources / view目录中存储html源代码。
我试过了,但它没有工作,因为它告诉我找不到资产。 (在这种情况下,为什么?资产在这里,并通过URL进行渲染)
{{ source(asset('assets/book/html/' ~ book.htmlsrc))}}
错误告诉我们:
Unable to find template "/project/web/assets/book/html/abbot_flatland.html"
通过检查网址http://127.0.0.1/project/web/assets/book/html/abbot_flatland.html
,我可以轻松访问它。
这是我的问题。 如何在我的树枝视图中呈现位于我的资源中的HTML文件。
编辑:根据@DarkBee的回答,我做了以下内容。
在我的config.yml上,我添加了这个。
twig:
paths:
'%kernel.root_dir%/../web/assets/uploads/html': uploads
然后,在我的视图中,只需要包含该文件。
{{ include('@uploads/' ~ book.htmlsrc) }}