conditional loop

Hello, someone can inform if is possoble to make a conditional loop that depend if the attribute is nil?

for exemple:

{% for boat in %}

{{ }}

{% endfor %}
name: Azimut
sell: yes

if the sell is not nil, show the boat

you want to know if it is nil? I think this would work inside your for loop:

{% if boat.sell  == nil %}
 //do cool stuff here
{% endif %}

If you want to show it if it is NOT nil then I think it would be:

{% if boat.sell  %}
 //do cool stuff here
{% endif %}

That is good. It checks both that the value is not nil and also that the value is defined with a key. Since if a key is missing and you do {{ page.bad_key }} then the value is nil

I’d go a step further and check the value is not empty. I use a CMS for some sites and if I don’t set a value it gets stored as a empty string, which is considered truthy by Jekyll (unlike in other programming languages).

So I would do. Assuming that say name is the minimum required field and that others like sell might or might be required.

{% if and != '' %}
 {{ }} - {{ boat.sell }}
{% endif %}