template code generation