I'm doing email development in this grunt enviroment: https://github.com/leemunroe/grunt-email-workflow
I've got a row of links that have a pipe in-between them. Naturally, I don't want the pipe on the last link.
This is what should work, but is not (from here):
{{#each page.footer.service_link }}
<a href="{{ link }}" style="text-decoration:none;">{{ name }}</a>
{{#unless @last}}
|
{{/unless}}
{{/each}}
I checked the version numbers and it should work with the versions installed.
If I try something like this:
{{#each page.footer.service_link }}
{{#unless @last}}
<a href="{{ link }}" style="text-decoration:none;">{{ name }}</a> |
{{/unless}}
<a href="{{ link }}" style="text-decoration:none;">{{ name }}</a>
{{/each}}
The result becomes:
LINK 1 | LINK 1 LINK 2 | . . . | LINK 4 LINK 5 | LINK 5
(notice no pipe at the end)
This is what my solution is, but I'm not satisfied with it, because it requires me to add an extra key to my yml file:
{{#each page.footer.service_link }}
<a href="{{ link }}" style="text-decoration:none;">{{ name }}</a>
{{#if pipe}}
|
{{else}}
{{/if}}
{{/each}}
This is the way I have my yml file set up:
footer:
service_link:
- name: "LINK 1"
link: "#"
pipe: true
- name: "LINK 2"
link: "#"
pipe: true
- name: "LINK 3"
link: "#"
pipe: true
- name: "LINK 4"
link: "#"
pipe: true
- name: "LINK 5"
link: "#"
pipe: false
I'm at a loss on what to do. Because it's email dev, I'm limited to what I can do with css. (Thanks Outlook and Gmail...) It seems like #unless is working, because the pipes get put in, but @last isn't stoping the last one from being rendered. This is my fist time using yaml, but even when I tried to put it in the json format, I got the same problem. I'm still kind of new to this environment in general, though.