首页 > 解决方案 > 如何使用 Liquid 捕获或分配多个条件?

问题描述

有什么方法可以使用 Liquid 捕获或分配多个条件?我想用它来管理我的代码,因为我将在许多地方使用相同的条件。

        {% capture brand_only %}
            template == 'index' 
            or template == 'page.topbright' 
            or template == 'collection.topbright' 
            or template == 'product.topbright'
            or template == 'page.sciencecan' 
            or template == 'collection.sciencecan' 
            or template == 'product.sciencecan'
            or template == 'page.zzzmoon' 
            or template == 'collection.zzzmoon' 
            or template == 'product.zzzmoon'
        {% endcapture %}

        {% if brand_only %}
            <div>CATEGORIES</div>
        {% endif %}

标签: shopifyliquid

解决方案


You might try this (not tested):

{% if [brand_only] %}
    Do something
{% endif %}

推荐阅读