Archives for April, 2008

T4 Template Design: Nested Template Class


Nested Template Class is one of T4 template design techniques that can be used to develop reusable templates. The main template is defined as a nested TextTransformation class inside of a class feature block.

T4 Template Design: Standalone Template


Standalone Template is one of T4 template design techniques that can be used to develop reusable templates. The using template uses T4 engine to compile the main template into a separate assembly and run the compiled code independently of the using template.

T4 Template Design: Template Method


Template Method is one of T4 template design techniques that can be used to develop reusable templates. It encapsulates the main template as a method in a class feature block. Template parameters are defined as parameters of the method. The calling template uses an include directive to merge code of the template method with the code of the calling template and calls the method from a statement block.

T4 Template Design: Merged Template Class


Merged Template Class is one of T4 template design techniques that can be used to develop reusable templates. It uses class feature blocks to define parameters as fields or properties in the main template. The calling template uses an include directive to merge code of main template with the code of the calling template and assigns parameter values in a statement block.

T4 Template Design


This article discusses design challenges developers face as complexity of their T4 templates increases; defines qualities of a reusable T4 templates; discusses techniques that can be used to achieve these qualities and compares their pros and cons.

Understanding T4: <#@ property #> directive


This article describes the purpose and implementation mechanics of the T4 <#@ property #> directive.