機能していないループ内に非常に基本的な条件があります。
{% for tag in collections.all.tags %}
<li class="mb-1 ">
<a class="text-white" title="{{ tag }}" href="#">
{{ tag | handle }}
{% if canonical_url contains tag | handle %}
active
{% endif %}
</a>
</li>
{% endfor %}
現在、私tag | handle
は「かわす」です。私が印刷すると、{{ canonical_url }}
私https://localhost:3000/collections/all/dodge
の条件は真実であると評価され、「アクティブ」という単語を印刷する必要があります。
ステートメントを変更すると正常に{% if canonical_url contains 'dodge' %}
機能しますが、動的にする必要があります。助言がありますか?