Search code examples
c#stringtemplate-4

Using comma as list separator with StringTemplate 4


I need to create a comma-separated list of items: $subjects : {sub | $sub.Name$}separator=", "$ This does not seem to work. What is the right way to use a separator? Is there an alternative way to create a comma-separated list of items?


Solution

  • The format is:

    <multi-valued-attribute; separator=expr>

    In your case it would be:

    subjects: $subjects:{sub | $sub.name$}; separator=", "$
    

    Which would render:

    subjects: Maths, English
    

    You can find out more from the StringTemplate cheat sheet