How to: Use Escape Sequences in Text Templates
Text template files support using an escape sequence to enable such things as quoted strings as demonstrated in the procedure below. Escape sequences can also be used to generate text template tags to output files or to create text templates from text templates. For more information, see.
Visual Basic does not support escape sequences to enable quoted strings.
Escape sequences are added to text templates using the escape character "\". For example, the following escape characters are used to retain text template tags in the output file:
\<# … \#>
If a text block is required that includes strings used to delimit other blocks, then the following escape sequences may be used:
If either of the two tags has an even number of escape (\) characters preceding it, then the following procedure will be applied: suppose there are 2n occurrences of \ before the tag, the 2n occurrences are replaced with n occurrences of \ in the post-parsing code and the tag is considered as a start/end tag.
If either of the two tags has an odd number of escape (\) characters preceding, then the following procedure will be applied: suppose there are 2n+1 occurrences of \ before the tag, the 2n+1 occurrences are replaced with n occurrences of \ plus the tag itself (<# or #>) in the post-parsing code. The tag is not considered as a start/end tag.
In the case of escape (\) appearing anywhere else in any other sequence (apart from escaping " in a directive block), it receives no special treatment. For example, \a, \<\#, #\> etc will be ignored by the parser and will lend no special significance to it. The \ will be left as it is in the post-parsing code.
To use escaping in a text template
In Solution Explorer, right-click the text template file that you want to edit and then click Open.
The template opens in the editor.
Use the escape character "\" as needed. For example, to retain the quoted string name, you can use the following syntax:
For an example of how to use escape sequences to generate a text template from within a text template, see.
To debug text templates you must set the debug parameter of the template directive. For more information, see.
For more information, see.