如何在 for 循环中使用 Liquid include 变量?

How to use Liquid include variable within a for loop?

我有这个 Liquid 模板,它看起来像这样:

# /_includes/slideshow.html
{% for image in {{ include.images }} %}
    ...
{% endfor %}

我正在尝试将其与 YAML 文件(用于我的 Jekyll 站点)一起使用,如下所示:

# /index.md
{% include slideshow.html images='site.data.homepage_images' %}

我看到此失败的原因是因为我的包含变量 {{ include.images }} 在 for 循环中解析为 string。有没有不同的方法来完成这个?我对 Liquid、YAML、Jekyll 以及 web 开发还是比较陌生,所以非常感谢任何对此的帮助!

(注意:如果我将 {{ include.images }} 替换为 site.data.homepage_images,问题就会消失。)

此外,我这样做的原因(以及为什么粗略的修复不是我正在寻找的解决方案)是为了能够在我网站的其他地方插入我的图像幻灯片。以这种方式滥用我的 include 变量会节省很多代码。

for 循环中的正确语法是:{% for image in include.images %}