Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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
    
    <#
       Next
    #>
    

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

Date

History

Reason

July 2008

Rewrote and refactored project.

Content bug fix.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.