title: Control the filename generated by a T4 template?
body: <p>How can I instruct a T4 template to generate the resulting file with a given file name?</p>
  
  <p>I'll try to be more clear. Let's say I have a template called Insert.tt that generates code to insert a record into a table. It has an output extension of "sql", so it creates a file called:</p>
  
  <p>Insert.sql</p>
  
  <p>That's OK, but I'd like the file name to reflect whatever it is I'm trying to do. Let's say that the name of the table I'm generating an Insert for is stored in &lt;#= TableName #>. I'd like to pass that to the template generator and have it use that to save the resulting file. </p>
  
  <p>i.e. &lt;# SaveTemplateAs("Insert" + TableName); #></p>
  
  <p>So let's say I generate Insert statements for tables User, Address and Phone.</p>
  
  <p>I want the resulting files to be named InsertUser.sql, InsertAddress.sql and InsertPhone.sql.</p>
  
  <p>I'm pretty sure this can be done as I've seen some custom extensions to generate multiple files from a single template, but I'm not understanding a simple (not overkill) way to make this happen.</p>
  
  <p>Thanks</p>