【问题标题】:liquid template `for` loop: how to `continue` to skip an iteration液体模板“for”循环:如何“继续”跳过迭代
【发布时间】:2015-02-21 01:50:14
【问题描述】:

我想根据条件跳过迭代。

我正在使用液体模板作为 Jekyll 的一部分。

我在文档中没有看到继续:

http://www.rubydoc.info/gems/liquid/Liquid/For

{% for page in site.pages %}
  {% if page.url == '/index.html' %}
    // Continue here
  {% endif %}
  {{ page.title }}
{% endfor %}

【问题讨论】:

    标签: jekyll liquid


    【解决方案1】:

    您可以使用continue 标签,其工作方式与任何其他语言中的continue 类似。它记录在单独的部分中:

    {% for page in site.pages %}
      {% if page.url == '/index.html' %}
        {% continue %}
      {% endif %}
      {{ page.title }}
    {% endfor %}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-23
      • 1970-01-01
      • 2014-09-06
      • 1970-01-01
      • 2021-11-15
      相关资源
      最近更新 更多