Feature: use template instead of StringBuilder

Please see PR #12 for details on this PR; this is basically the same PR.

Note that the original PR was against the develop branch - I think it got closed once that branch was deleted.

To do before this can be pulled in:

 * [ ]  review 274da219d85341e4c599feef1a976be877d0d81e and add any new functionality here
 * [ ] make sure it can be automatically merged (not quite sure why we can't ATM