Reputation: 121
Hi there i added on footer section a list of policies (shop.policies) with an output like:
Privacy Policy Terms of service
Then i added append filter append on array, like:
{{ policy.title | append: ' /' }}
with an output:
Privacy Policy / Terms of service /
How can i remove the last ' /' on that string?
Thanks in advance community
EDITED:
added part of code where it is needed.
<ul class="list list-policies">
{%- for policy in shop.policies %}
<a
href="{{ policy.url }}"
rel="noopener noreferrer"
class="text-xs tracking-tighter uppercase font-bold"
title="{{ policy.title }}"
>
{{ policy.title | append: ' /' | remove_last: '/' }}
</a>
{%- endfor %}
</ul>
Upvotes: 0
Views: 239
Reputation: 2584
Okay, thanks for sharing the full code, it loop the array and append and remove the '/' same time.
You need to check the loop and then add the '/'
<ul class="list list-policies">
{%- for policy in shop.policies %}
<a
href="{{ policy.url }}"
rel="noopener noreferrer"
class="text-xs tracking-tighter uppercase font-bold"
title="{{ policy.title }}"
>
{{ policy.title }}{% unless forloop.last %} / {% endunless %}
</a>
{%- endfor %}
</ul>
You need to check the forloop
last
using the forloop.last
and if not last then append the '/' after the title.
You can also read more the forloop here
Upvotes: 1