Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

liquid template `for` loop: how to `continue` to skip an iteration

Tags:

jekyll

liquid

I would like to skip an iteration based on a condition.

I'm using liquid templates as part of Jekyll.

I don't see a continue in the docs:

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

{% for page in site.pages %}
  {% if page.url == '/index.html' %}
    // Continue here
  {% endif %}
  {{ page.title }}
{% endfor %}
like image 235
SimplGy Avatar asked Dec 05 '22 04:12

SimplGy


1 Answers

You can use the continue tag, which works just like a continue in any other language. It's documented in a separate section:

{% for page in site.pages %}
  {% if page.url == '/index.html' %}
    {% continue %}
  {% endif %}
  {{ page.title }}
{% endfor %}
like image 143
SimplGy Avatar answered Feb 25 '23 01:02

SimplGy