Not last in the menu list?
I'm new to writing templates and I want to create a menu like this
item1 - item2 - item3 - item4
My problem is that only want the '-' between the items. With the help of 'last' I can write something like this
{{#menu}}
<a href="{{url}}" title="{{label}}">{{label}}</a> -
{{#last}}
<a href="{{url}}" title="{{label}}">{{label}}</a>
{{/last}}
{{/menu}}
Which of course results in two 'item4'. What I haven't figured out is how to match 'this items isn't the last item'.
Can anyone tell me how to do this
You can achieve the desired menu like so:
{{#menu}}
<a href="{{url}}" title="{{label}}">{{label}}</a>
{{^last}} - {{/last}}
{{/menu}}
The trick is to use a caret (^) instead of a pound sign (#) to invert the block. You can read more under inverted sections in the developer documentation.
Answered 2 years ago · Edit answerAhhh, for some reason I though ^ only worked on lists ... stupid me
Answered 2 years ago · Edit answerNo worries – your blog's menu is a list. Please let me know if you have any questions about this or anything else
Answered 2 years ago · Edit answer