Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ProcessTemplate Method
Collapse the table of content
Expand the table of content

Engine.ProcessTemplate Method

Transforms the contents of a text template file to produce the generated text output.

Namespace:  Microsoft.VisualStudio.TextTemplating
Assembly:  Microsoft.VisualStudio.TextTemplating.12.0 (in Microsoft.VisualStudio.TextTemplating.12.0.dll)

public string ProcessTemplate(
	string content,
	ITextTemplatingEngineHost host


Type: System.String

The contents of the text template file to be transformed.

Type: ITextTemplatingEngineHost

The ITextTemplatingEngineHost that will host this engine.

Return Value

Type: System.String
The generated text output of the text template file.


ITextTemplatingEngine.ProcessTemplate(String, ITextTemplatingEngineHost)


content is null.


host is null.

In Visual Studio, if a file has its Custom Tool property set to TextTemplatingFileGenerator, clicking Run Custom Tool in the user interface corresponds to calling ProcessTemplate to transform the template.

For more information, see How to: Create Text Templates and Processing Text Templates by using a Custom Host.


If you are writing a package or extension that will run within Visual Studio, consider using the text templating service instead of writing your own host. For more information, see Invoking Text Transformation in a VS Extension.

The following example demonstrates how to create an instance of the Engine, and calling ProcessTemplate to transform a text template.

This code example is part of a larger example provided for the ITextTemplatingEngineHost interface.

Engine engine = new Engine();

//read the text template
string input = File.ReadAllText(templateFileName);

//transform the text template
string output = engine.ProcessTemplate(input, host);

© 2015 Microsoft