Using template language to generate dot files

I wonder if we have any example for using a template language to generate the dot files. I’m trying to rewrite my plugin Graphvidian (importing data from Obsidian).

Good question. This is an on-going need.
Here are some answers from the forum & from stackoverflow:

Not entirely sure if this is what the OP is after, but the Graphviz language is partly designed such that the C pre-processor can be used on sources. So you can do some creative things with C macros.

For something more advanced you might want to use something like Jinja.

Are there any project that already use template language for graphviz so that I can use and don’t have to reinvent the wheel?

You might search github & gitlab, otherwise reinventing the wheel.

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.

if there is no problem from string-escaping, would there be any other advantages of using the API to build up the dot string?

Depends what problem you’re trying to solve?

Well I just want to auto generate graphs with data from Obsidian API (Javascript)