Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

How to: Add a Statement to Text Templates

Updated: July 2008

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 by using the language that is declared in the language parameter of the template directive.

To add a statement to a text template

  • In text templates, use an opening "<#" tag and a closing "#>" tag to delineate code statements. 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.

       foreach(ModelType type in this.ClassModel.Types)
            // templateblocks

       Dim type as ModelType
       For Each type in Me.ClassModel.Types
            // template blocks

For an example about how to create a fully coded and running text template, see Walkthrough: Creating and Running Text Templates




July 2008

Rewrote and refactored project.

Content bug fix.

Community Additions

© 2015 Microsoft