Re: [mustache] Mustache improvement suggestion: need a way to set
markup *between* list items, not around
- From:
- Pieter V.
- Date:
- 2011-03-24 @ 02:19
There are a number of solutions that "almost work", but too few that
actually do, I agree.
The simplest solution I can come up with off the top of my head (that
*actually* works) is this:
Mustache.render '{{list}}', { :list => proc { list.join(', ') } }
=> "bob, joe, walter"
Obviously enough, that's not actually a solution, and for some cases, simply
pushing that logic down into your View class doesn't fix it either.
New syntaxes are easy to contrive (e.g. `{{# list [separator] }}`,
`{{#list}}{{.}}{{*sep}}{{/list}}`), but I feel that if the pattern of "write
/ inject this for all but the final iteration" can be addressed -- simply --
by the current syntax, we need to not only acknowledge it but document it
well. This is a fairly common problem, and should have a simple solution.