2016-09-17 55 views
1

我无法找到液体/ jekyll是否可以处理while循环的任何信息。所以要么没有人问这个问题,要么Google没有太大的帮助。这是不是可以做的事情?我本质上喜欢能够做到这样的事情:如何在液体/ jekyll中做一个while循环?

<!-- 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 %} 

回答

4

没有while循环在Liquid中。

你可以使用一个像这样循环为您的要求

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

固体。谢谢。 –