shopify - 如何使用 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 %}
解决方案
You might try this (not tested):
{% if [brand_only] %}
Do something
{% endif %}
推荐阅读
- javascript - 在 Chrome、Firefox 和 edge 中工作但在 IE 或 Sarfari 中不工作的编码
- html - Css:设置身体高度= 100%的页脚
- python-2.7 - 视频的 TFRecords
- javascript - 如何以正确的格式将文件写入 mpeg 电影文件到磁盘?
- android-gradle-plugin - Gradle“排除”故障排除:对 protobuf-java 和 protobuf-lite 的嵌套依赖项
- javascript - 如何修复 appendChild() 以创建 div 元素节点?
- ios - 我在collectionview中的自动调整单元格大小调整了两次
- reactjs - 有没有办法让状态在正确的时间更新?
- sql - 仅显示从特定时间范围内增加的记录
- python - 还有比这更好的运行时分析方法吗?