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