Added support for using user-defined templates during generation.