mustache-sharp
mustache-sharp copied to clipboard
Created a Delimiter tag that allows nicely delimited lists
A common requirement is to have a list with a delimiter that is not shown for the final item - i.e. 1, 2, 3
instead of 1, 2, 3,
. This is often accomplished using the string.Join
method in C#.
With this pull request, content between delimiter tags will only be shown when not on the final item.
The implementation does not introduce any performance changes as I implemented a custom iteration block such that there is no chance for double-enumeration or requirement for the count/length.
I added two unit tests, and all tests pass.
I realised after pushing this that other variations of mustache use the 'delimiter' keyword to change the bracketing. Maybe a better tag for this new delimiter would be 'separator', or a short form like 'sep'. I would be happy to change the pull request.