Here are a series of useful links for the T4 code generation tool.
http://www.olegsych.com/2008/02/t4-text-blocks/
http://www.olegsych.com/2008/03/how-to-generate-multiple-outputs-from-single-t4-template/
T4 is useful yet rather limited. You can normally only generate one file per template.