while-loop - 如何在液体/jekyll 中做一个while 循环?

标签 while-loop jekyll liquid

我找不到关于 Liquid/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 %}

最佳答案

Liquid 中没有 while 循环。

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

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

关于while-loop - 如何在液体/jekyll 中做一个while 循环?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39551301/

相关文章:

ruby - 在任何来源中都找不到 public_suffix-2.0.4

python - 看不懂这个定时while循环属性报错

c - While 循环自身的迭代次数比应有的多或少

ruby - Kramdown/Rouge 不突出语法?

ruby - 如何去除 jekyll 中的换行符?

variables - Jekyll - 将 jekyll 变量传递给自定义液体标签

java - 适当使用Java中的Multi-level Break

c - 在 while 循环中重置值

shopify - uri 编码 shopify url 到文章

html - 你能解释一下为什么在 html 中使用标签 {{ , }} 吗?