Domain-Specific Language Tools Reference
TextTransformation..::.PopIndent Method

Updated: November 2007

Removes the most recently added text from CurrentIndent.

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

Syntax

Visual Basic (Declaration)
Public Function PopIndent As String
Visual Basic (Usage)
Dim instance As TextTransformation
Dim returnValue As String

returnValue = instance.PopIndent()
C#
public string PopIndent()
Visual C++
public:
String^ PopIndent()
JScript
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.

C#
<#
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();
#>
Visual Basic
<#
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

Reference

Other Resources

Tags :


Page view tracker