Handling the last list item differently in rudders # each block
Possible duplicate:
How do I add a separator between elements in a {{#each}} loop, except for the last element?
For the simplest case, let's say I have a list of names and I want them to appear with commas in between. I could do
{{#each name in names }} {{name}}, {{/each}}
which will then produce the last
John, Paul, George, Ringo,
with a trailing comma, which is not needed. I can figure out how to handle this by adding commas to my controller functions, but that seems like an awkward and awkward violation of MVC separation. Is there a steering wheel-only way to detect when you are dealing with the last item and adjust accordingly?
+3
source to share
2 answers