当我使用
{% include folder1/folder1_1/img.jpg %}它运作完美,但当我尝试动态生成文件名时,让我们说:
{%capture filename %} {{'folder1/folder1_1/'}}{{ images[0] }}{{ '.jpg' }}{% endcapture %} {% include {{ filename }} %}以images[0] = 'img'为例,我得到的错误是:
Liquid Exception: Invalid syntax for include tag. File contains invalid characters or sequences ...我不明白为什么包含文件通过提供完整的路径(静态路径)工作,而动态生成文件名将无法正常工作!
任何帮助都不仅仅是值得赞赏的。
When i use
{% include folder1/folder1_1/img.jpg %}it works perfectly, But when i try to generate the filename dynamically let's say :
{%capture filename %} {{'folder1/folder1_1/'}}{{ images[0] }}{{ '.jpg' }}{% endcapture %} {% include {{ filename }} %}with images[0] = 'img' for example, i get the error that says :
Liquid Exception: Invalid syntax for include tag. File contains invalid characters or sequences ...I Don't understand why including file by providing the complete path(static path) works whereas generating the filename dynamically won't work !
Any help would be more than appreciated.
最满意答案
经过对互联网的更多研究后,似乎无法添加动态文件名路径,因为所包含的文件是在编译阶段计算和添加的,而不是在运行时阶段 。
编译阶段意味着尚未识别动态路径。
After more research on the internet it seems that dynamic filename paths can't be added due to the fact that the included files are calculated and added at the compilation phase and not at run time phase.
And compilation phase means dynamic paths aren't yet recognized.
更多推荐
发布评论