2013-03-11 68 views
3

我想用另一個t4模板來輸入,而不是this.WriteLine(「Hello,World!」); 。那可能嗎?T4模板多輸出

<#@ template language="C#" hostspecific="True" debug="True" #> 

<#@ output extension="txt" #> 
<#@ include file="T4Toolbox.tt" #> 

Sample Content 

<# for(int i=7;i<9;i++){ 

     SampleTemplate template = new SampleTemplate(); 
     template.Output.File = @"SubFolder\SampleOutput"+i+".txt"; 
     template.Output.Project = @"..\ClassLibrary2\ClassLibrary2.csproj";   
     template.Render(); 
    } 
#> 


<#+ 
    public class SampleTemplate : Template 
    { 
     public override string TransformText() 
     {    
      this.WriteLine("Hello, World!"); 

      return this.GenerationEnvironment.ToString(); 
     } 
    } 
#> 

回答