Using template language to generate dot files

The tricky bit in templating is usually the string-escaping for different contexts. So you probably can’t just use (say) an HTML templating engine and use that for Graphviz; Graphviz probably has different escaping rules for strings.

Without knowing much about your problem you’re trying to solve, usually instead of templating, I’d encourage using Graphviz libraries/APIs to build up a dot-string then output that. Less likely to screw up the string-escaping.