generate code from a given template