I'm completely with you. Generating a data structure using a text templating language is just awkward and error prone. In fact I'm starting to think that text templates are very rarely the best option. It is usually better to have a proper emitter library or AST data structure that can be generated with "real" code.
I guess one of the few places that text templates can provide value is when the template is untrusted. But maybe a sandboxed programming language is still a better option here.
I guess one of the few places that text templates can provide value is when the template is untrusted. But maybe a sandboxed programming language is still a better option here.