在 Shopify 模板中,我创建了一个链接
<a href="{{ featured.url | within: collection }}" class="grid-link-slider">
Run Code Online (Sandbox Code Playgroud)
我需要检查 url 是否包含某个单词“明信片”,如果是,则设置第二个类。很遗憾,
<a href="{{ featured.url | within: collection }}" class="grid-link-slider {% if {{ featured.url | within: collection }} contains "postcard" %}grid-link-postcard{% endif %}">
Run Code Online (Sandbox Code Playgroud)
不起作用,“contains”只能用于字符串,而且语法肯定是无效的。有办法解决这个问题吗?