template-archive
template-archive copied to clipboard
Extend 'separators' that are supported in join blocks
At the moment, a simple separator can be set by the user that will be inserted between all values in an array when populating a template.
So, for example:
TemplateMark:
Discount applies to the following items: {{#join items separator=", "}}{{name}} ({{id}}){{/join}}
will accept an array of
{{"name": "Pineapple", "id": 111}, {"name": "Strawberries", "id": 222}, {"name": "Pomegranate", "id": 333}}
to give:
Discount applies to the following items: Pineapple (111), Strawberries (222), Pomegranate (333)
Each list item is separated by a comma.
Request: There should be support for specifically setting the standard, penultimate and final separators. This is already done in other doc generation tools which use the | symbol is used to indicate the punctuation as "list item | penultimate item | final item"
Example syntax:
;|; and|.
So, the example above with the new functionality would be:
TemplateMark:
Discount applies to the following items: {{#join items separator=",|and|. "}}{{name}} ({{id}}){{/join}}.
will accept an array of
{{"name": "Pineapple", "id": 111}, {"name": "Strawberries", "id": 222}, {"name": "Pomegranate", "id": 333}}
to give:
Discount applies to the following items: Pineapple (111), Strawberries (222) and Pomegranate (333).