Hi everyone,
I was reviewing the Shopify Liquid documentation under the “Whitespace control” section and came across an example that lists all product types in a collection. The example shows output like:
The 'Sale potions' collection contains the following types of products:
- Health
- Health & Beauty
- Invisibility
- Water
However, in my testing, when collection.products is empty, using the following code prevents the types from being displayed:
{%- if collection.products.size > 0 -%}
The '{{ collection.title }}' collection contains the following types of products:
{% for type in collection.all_types -%}
{% unless type == blank -%}
- {{ type }}
{%- endunless -%}
{%- endfor %}
{%- endif -%}
Test data used:
{
"collection": {
"all_types": [
"Health",
"Health & Beauty",
"Invisibility",
"Water"
],
"products": [],
"title": "Sale potions"
}
}
This behavior differs from the example output shown in the documentation.
Could anyone clarify whether this is a documentation oversight, or if there is a specific context in which the example output is accurate?
Thanks in advance for your guidance.
Best regards,
Masud Rana