- Source: Text Template Transformation Toolkit
A Legend (2024)
The Fix (2024)
No More Posts Available.
No more pages to load.
Text Template Transformation Toolkit (usually referred to as "T4") is a free and open-source template-based text generation framework. T4 source files are usually denoted by the file extension ".tt".
Overview
T4 is used by developers as part of an application or tool framework to automate the creation of text files with a variety of parameters. These text files can ultimately be any text format, such as code (for example C#), XML, HTML or XAML.
T4 uses a custom template format which can contain .NET code and string literals in it, this is parsed by the T4 command line tool into .NET code, compiled and executed. The output of the executed code is the text file generated by the template. By using the Text Transformation class, T4 can also be run entirely from within a .NET application, eliminating the need for the end user to have Visual Studio installed.
T4 is used within Microsoft in ASP.NET MVC for the creation of the views and controllers, ADO.NET Entity Framework for entity generation, and ASP.NET Dynamic Data. It is also used outside of Microsoft in projects such as SubSonic.
T4 templating is supported in Visual Studio, MonoDevelop and JetBrains Rider.
Controls
There are four types of controls handled by the T4 template transformation engine.
History
2005: Microsoft released the first version of T4 as an out-of-band release for Visual Studio 2005
2008: Microsoft includes it with Visual Studio 2008
2010: Microsoft includes it with Visual Studio 2010 which included significant new features to improve performance, usability for both template authors and tool builders and better integration into Visual Studio's DSL tools.
2015: Visual Studio 2015 Update 2 can use C# version 6.0 features
2017: Open source version of engine released which supports .NET Core
2019: JetBrains adds support for T4 in Rider
See also
Comparison of code generation tools
m4 (computer language)
Smarty
References
External links
GitHub - mono/t4: T4 text templating engine