TextTransformation.PopIndent Method
Removes the most recently added text from CurrentIndent.
Namespace: Microsoft.VisualStudio.TextTemplating
Assembly: Microsoft.VisualStudio.TextTemplating.12.0 (in Microsoft.VisualStudio.TextTemplating.12.0.dll)
Syntax
'Declaration
Public Function PopIndent As String
public string PopIndent()
public:
String^ PopIndent()
member PopIndent : unit -> string
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
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
Microsoft.VisualStudio.TextTemplating Namespace