How to: Call a Custom Directive
When you create a text template, you can call one or more of the five built-in directives: assembly, import, template, output, and include. For example, you call the output directive by using the following syntax:
<#@ output extension=".txt" #>
In addition to calling built-in directives, you can also call custom directive processors. For more information, see Architecture of the Text Template Transformation Process.
To call a custom directive processor from a text template, you must add an extra parameter for the name of the directive processor. The name of the directive processor matches the name of the directive processor's key in the registry. For more information, see How to: Set Registry Keys for Custom Directive Processors.
To call a custom directive processor
In your text template file, add a custom directive statement, and specify the name of the directive processor.
The syntax is the following:
<#@ DirectiveName Processor="DirectiveProcessorName" ParameterName="ParameterValue" #>
For example, use the following syntax to call the CoolDirective custom directive, which is located in a directive processor named CustomDirectiveProcessor and that requires a parameter named FileName:
<#@ CoolDirective Processor="CustomDirectiveProcessor" FileName="C:\UserFiles\data.xml" #>
注意
To debug text templates, you must set the debug parameter of the template directive. For more information, see How to: Debug Text Templates.
Security
For more information, see Security of Text Templates.
See Also
Concepts
Walkthrough: Creating a Custom Directive Processor
How to: Set Registry Keys for Custom Directive Processors