in reply to config tokens substitutions

We don't do homework assignments here.

Having said that, maybe you want to show us the code you already have, and explain to us what it should do, what its input data is, what it should ouput and how it fails for you? Then we can help you with your specific problems.

Alternatively, I'd just use Template Toolkit to fill out templates, but you'd have to rewrite your templates to fit in the TT syntax.