Some Activity Scorecard for John Doe
Group One:
15/ 15 Item One
3/ 10 Item Two
----------
18/ 25 Total
Group Two:
-/150 Item Three
----------
0/150 Total
Some blurb, with precisely one line separating it from the previous text,
regardless of the branch taken.
----------------------------
What would be rather useful is if the same output could be produced without having to hack at the template to get spacing and newlines right. In particular, in contrast to html/template (since html has collapsing whitespace rules), I find templates oriented for precise text output must by nature be extremely unreadable at times, and do not lend themselves to efficient line editing -- two unrelated pieces of template code often must share the same line. Newlines can sometimes be shifted from the inside of a block to the outside, or vice versa, but the readability of the template code is rarely cleaned up by doing so.
I would like to be able to write a template to produce the same output like so:
----------------------------
{{.Activity}} Scorecard for {{.Person.Name}}
{{range .Person.Groups \}}
{{.Name}}:
{{range .CurrScores \}}
{{/*tab*/}}
{{score .Score .Scored}} {{.Name}}{{end \}}
----------
{{/*tab*/}} {{score .CurrTotal true}} Total
{{else \}}
No groups found
{{end \}}
Some blurb, with precisely one line separating it from the previous text,
regardless of the branch taken.
----------------------------
Here, I'm using a hypothetical '\' modifier as the last character of a template action to signify that the following newline should be ignored. I don't really care about the mechanism, as long precise control can still be maintained, and a post-process step is not required (which usually sacrifices control, if the formatting requirements are more complex than "no more than one blank line between text blocks").
Even nicer would be a template flag (settable during parse) that causes the literal-text portion of an entire line to be ignored if it only contains whitespace and an action (allowing benign indentation of nested actions for clarity).