Expression Syntax (Domain-Specific Languages)
Updated: July 2008
You can use expression blocks in text templates to add strings to the generated text output. Expression blocks contain code that is first added to the generated transformation class with calls to ToString() attached to them. The transformation process will also apply the template's culture to the generated string. Typically, expression blocks are embedded inside text blocks. They are designed to change some aspect of the generated output text to use calculated values from external data, such as model files.
In text templates, expression blocks are delineated by using opening (<#=) and closing (#>) text template tags. The general syntax is:
<#= ExpressionCode #>
Expressions must be on a single line in Visual Basic templates. Expressions can be on multiple lines in Visual C# templates.
The following code sample shows an expression:
<#= operation.Name #>
The following code sample shows a statement that performs a calculation, and then shows an expression that adds the result as a string to the generated text output:
The result of the previous example in the generated text is: