mustache-sharp icon indicating copy to clipboard operation
mustache-sharp copied to clipboard

Created a Delimiter tag that allows nicely delimited lists

Open Andrew-Hanlon opened this issue 7 years ago • 1 comments

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.

Andrew-Hanlon avatar Jan 29 '17 22:01 Andrew-Hanlon

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.

Andrew-Hanlon avatar Jan 30 '17 03:01 Andrew-Hanlon