You can use text templates to generate code, XML, reports, or other artifacts from models. You can use Statement Syntax blocks to add Visual Basic or Visual C# code to your template. The code should be expressed using the language that is declared in the language parameter of the template directive.
To add a statement to a text template
-
In Solution Explorer, right-click the text template file that you want to edit, and then click Open.
The template opens in the editor.
-
In text templates, you delineate code statements using an opening "<#" tag and a closing "#>" tag. Add statement tags to your text template with code, as shown in the following example. In this example, the code loops through each ModelType in ClassModel.Types:
<<b>#</b>
foreach(ModelType type in this.ClassModel.Types)
{
<b>#</b>>
// templateblocks
<<b>#</b>
}
<b>#</b>>
<<b>#</b>
Dim type as ModelType
For Each type in Me.ClassModel.Types
<b>#></b>
// template blocks
<b><#</b>
Next
<b>#></b>
For an example of how to create a fully coded and running text template, see Walkthrough: Creating and Running Text Templates
Note |
|---|
| To debug text templates, you must set the debug parameter of the template directive. For more information, see How to: Debug Text Templates. |
Security
See Also