不接受液体动态文件名(Liquid dynamic filename is not accepted)

编程入门 行业动态 更新时间:2024-10-09 01:14:15
不接受液体动态文件名(Liquid dynamic filename is not accepted)

当我使用

{% 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.

更多推荐

本文发布于:2023-08-02 08:29:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1372691.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不接受   文件名   液体   动态   accepted

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!