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

How to: Add an Expression to Text Templates

Updated: July 2008

You can use text templates to generate code, XML, reports, or other artifacts from models. A text template file contains a mixture of text blocks and control logic. Use the control logic to combine the text blocks with the data from a model to produce an output file.

The Expression Syntax (Domain-Specific Languages) block contains strings that are generated in the culture that is specified in the culture parameter of the template directive. Use the Expression Syntax (Domain-Specific Languages) block to add an expression. For more information, see How to: Specify a Culture in Text Templates.

To add an expression to a text template

  1. Use an opening "<#=" tag before each code expression and a closing "#>" tag after each.

  2. Add the following expression to the template.

    <#
       foreach(ModelType type in this.ClassModel.Types)
       {
          if (type is ModelClass)
          {
    #>
             <#= type.Name #>
    <#
          }
       }
    #>
    

    <#
       Dim type as ModelType
       For Each type in Me.ClassModel.Types
          If TypeOf(type) Is ModelClass Then
    #>
             <#= type.Name #>
    <#
          End If
       Next
    #>
    

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.