Some years ago amrita or so was "more" actively developed. IIRC misen
was an effort to create a template engine that provides the kind of
flexibility you're looking for. Or maybe not. Both projects seem
rather moribund now though.

If you use a gsub-based solution (as proposed by Scytrin), you might
also want to think about how to escape the markers.