我正在努力弄清楚如何在Liquid/Jekyll中的for循环中增加索引变量.目前,我有类似的东西
{% for i in (0..num_posts) %}
{% if i < some_value %}
do_thing
{% else %}
{% endif %}
{% assign i = i|plus:1 %}
{% if i<some_value %}
do_another_thing
{% else %}
{% endif %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
问题是,它不是递增i,而是将i保留为相同的值.
我尝试过的事情:
{% assign i = i|plus:1 %}.{% increment i %}.运用
{% assign j = i|plus:1 %}
{% assign i = j %}
Run Code Online (Sandbox Code Playgroud)我无法使用该offset命令,因为代码并不总是只检查循环中的2个if语句.
有任何想法吗?