如何在liquid / jekyll中进行while循环?

时间:2016-09-17 20:17:33

标签: while-loop jekyll liquid

我找不到关于liquid / jekyll是否可以处理while循环的任何信息。所以要么没有人问这个问题,要么Google没有帮助。这不是可以做的事吗?我基本上希望能够做到这样的事情:

<!-- creates the 'counter' variable-->
{% assign counter = 0 %}
<!-- while 'counter' is less than 10, do some stuff -->
{% while counter < 10 %}
  <!-- the stuff to be done followed by an increase in the 'counter' variable -->
  {% assign counter = counter | plus: 1 %}
<!-- the completion of the loop -->
{% endwhile %}

1 个答案:

答案 0 :(得分:6)

没有在Liquid中循环。

您可以根据需要使用这样的for循环

{% for counter in (0..9) %}
  <!-- the stuff to be done followed by an increase in the 'counter' variable -->
    {{ counter }}
{% endfor %}