Use custom placeholder substitution code for template instantiation

This is to have better control over code that might constitute
a security concern for the templating mechanism.