Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
How to: Generate HTML from Text Templates

How to: Generate HTML from Text Templates

Updated: July 2008

You can use text templates to generate reports as HTML documents for the Internet. Text templates let you generate HTML and include valid HTML in text blocks. These templates ensure that any expressions and write statements will output valid HTML. The following procedure shows how to create a template that generates HTML.

To create HTML from a text template

  1. Under the directives in your existing code, type your html text.

    For example:

    <#@ template inherits="Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation"#>
    <#@ ClassDiagramExample processor="ClassDiagramExampleDirectiveProcessor" requires="fileName='Sample.testcd'" #>
    <#@ output extension=".htm" #>
    <html>
    <h1>ModelClass</h1> 
    <ul>
    <#
       foreach(ModelType type in this.ClassModel.Types)
       {
    #>
    <#
       if(type is ModelClass)
       {#>
    <li/><#=type.Name#>
    <#
       }
    #>
    <#
    }
    #>
    </ul>
    </html>
    
  2. Right-click the generated file and then click View In Browser.

Output that has HTML formatting should be displayed.

Date

History

Reason

July 2008

Rewrote and refactored project.

Content bug fix.

Community Additions

ADD
Show:
© 2015 Microsoft