TextTransformation.PopIndent Method

Removes the most recently added text from CurrentIndent.

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

Syntax

'宣言
Public Function PopIndent As String
'使用
Dim instance As TextTransformation
Dim returnValue As String

returnValue = instance.PopIndent()
public string PopIndent()
public:
String^ PopIndent()
public function PopIndent() : String

Return Value

Type: System.String

A String that contains the text most recently added to CurrentIndent. CurrentIndent is commonly called without capturing the return value.

Remarks

The CurrentIndent represents text that is prefixed to each line of the generated text output. The indent text can be spaces only, for example "    ", or it can include words. PushIndent adds text to CurrentIndent, and can be called more then once. PopIndent removes the most recently added text from CurrentIndent, and can be called more than once. ClearIndent removes all text from the CurrentIndent.

Examples

The following code example demonstrates calling the PopIndent method from a text template. Paste this code into any text template file and run the text template transformation to see the results.

<#
PushIndent("Indent1>  ");
PushIndent("Indent2>  ");

WriteLine("Test");

string previous = PopIndent();
WriteLine("The previous indent was: {0}", previous);

PopIndent();  //Pop without capturing the return value.
WriteLine("Test");

ClearIndent();
#>
<#
PushIndent("Indent1>  ")
PushIndent("Indent2>  ")

WriteLine("Test")

Dim previous as String = PopIndent()
WriteLine("The previous indent was: {0}", previous)

PopIndent()  'Pop without capturing the return value.
WriteLine("Test")

ClearIndent()
#>

This example produces the following output:

Indent1> Indent2> Test

Indent1> The previous indent was: Indent2>

Test

Permissions

See Also

Concepts

Generating Artifacts Using Text Templates

Reference

TextTransformation Class

TextTransformation Members

Microsoft.VisualStudio.TextTemplating Namespace

CurrentIndent

PushIndent

ClearIndent