This documentation is archived and is not being maintained.

Generating Artifacts Using Text Templates 

Domain-Specific Language Tools includes a text template transformation toolkit that supports the processing of text templates. A text template is a file that contains a mixture of text blocks and control logic. When you transform a text template, the control logic combines the text blocks with the data in a model to produce an output file. You can use text templates to create text artifacts such as code files and HTML reports. For example, a model of the flow of control between the individual pages in a user interface, such as a wizard, can be passed as input to a text template. The text template can generate code and configuration files that implement that flow of control.


All domain-specific language solutions include a debugging solution. The debugging solution is started whenever you press F5 or Ctrl+F5 from your domain-specific language solution. The debugging solution includes two sample text templates: one in Visual C# and one in Visual Basic. For more information, see How to: Test Domain-Specific Language Solutions.

The following are examples of tasks that you can perform by using text templates:

  • After creating models, you can iterate over their in-memory-representation (instead of their raw XML representation) to generate arbitrary text.

  • You can generate custom code by using either Visual C# or Visual Basic to navigate through a model.

  • You can generate custom reports in XML or HTML.

In This Section

Architecture of Text Templates

Contains topics that discuss the architecture of the text template transformation process in detail.

Security of Text Templates

Explains security concerns with text templates, such as running arbitrary code and malicious directive processors.

Basic Text Template Tasks

Contains topics that list the steps for basic text template tasks, such as opening and running text templates.

Using Built-in Directives in Text Templates

Contains topics that explain how to use built-in directives, such as output and include, in text templates.

Adding Code to Text Templates

Contains topics that explain how to add code, such as statements and expressions, to text templates.

Generating Specific Types of Artifacts from Text Templates

Contains topics that show examples of how to create different types of output, such as HTML and code, from text templates.

Text Template Walkthroughs

Contains walkthroughs that provide step-by-step instructions for common text template scenarios.

Advanced Tasks with Text Templates

Contains topics about advanced text template tasks, such as how to create custom host and directive processor components.

Troubleshooting Text Templates

Contains topics to help you debug common text template errors.

Command-Line Tools for Text Templates

Explains the TextTransform and DslTextTransform command line tools.


Related Sections

Domain-Specific Language Commands

Describes the command-line tool for Domain-Specific Language Tools.

Creating Domain-Specific Language Solutions

Describes the solution templates that you can use to create different types of domain-specific language solutions by using Domain-Specific Language Tools.

Getting Started with Domain-Specific Languages

Provides an introduction to Domain-Specific Language Tools.

Domain-Specific Language Tools Glossary

Defines key terms that are used in the Help for Domain-Specific Language Tools.