What is the difference between the <#
tag and the <#+
tag in T4?
views:
47answers:
2The docs explain:
Standard control blocks
A standard control block is a section of program code that generates part of the output file.
You can mix any number of text blocks and standard control blocks in a template file. However, you cannot place one control block inside another. Each standard control block is delimited by the symbols
<# ... #>
....
Class feature control blocks
A class feature control block defines properties, methods, or any other code that should not be included in the main transform. Class feature blocks are frequently used for helper functions. Typically, class feature blocks are placed in separate files so that they can be included by more than one text template.
Class feature control blocks are delimited by the symbols
<#+ ... #>
For example, the following template file declares and uses a method:
<#@ output extension=".txt" #> Squares: <# for(int i = 0; i < 4; i++) { #> The square of <#= i #> is <#= Square(i+1) #>. <# } #> That is the end of the list. <#+ // Start of class feature block private int Square(int i) { return i*i; } #>
A class feature control block is a block in which you can define auxiliary methods. The block is delimited by <#+...#>
and it must appear as the last block in the file. Ref