Statement Syntax

Updated: July 2008

You can use statement blocks in text templates to control the flow of processing in the text template. Statement blocks enable you either to structure templates to output things conditionally or to iterate over data to output things repeatedly for each item in that data.

Code statements are delineated using opening (<#) and closing (#>) text template tags. The general syntax is as follows.

<# StatementCode #>

You should use the language declared in the language parameter of the template directive to write the code statements. The code statement must compile successfully.

NoteNote:

C# is the default text template language. For more information, see How to: Specify a Language in Text Templates.

The following example shows a C# code statement in a text template.

<# WriteLine("Hello"); #>

The following example shows a code statement on more than one line in a text template.

<#
    for(int i=0; i<4; i++)
    {
        WriteLine("Hello");
    }
#>

The following example shows an alternate version of the same statements.

<#
    for(int i=0; i<4; i++)
    {
#> 
<#
        WriteLine("Hello");
#>        
<#
    }
#>

Date

History

Reason

July 2008

Rewrote and refactored project.

Content bug fix.

Community Additions

ADD
Show: