The Editor and Display templates in MVC are very similar to partial views. They display data based on the model provided. You may have seen DisplayFor or EditorFor when you scaffold a View in MVC. You could customize DisplayFor to display an editable form but the convention is for DisplayFor to be read-only and EditorFor is for editing. Both Editor and Display templates can be used on a per Controller basis by the convention of placing them the folder: Views/ControllerName/DisplayTemplates
Text Template Transformation Toolkit, also known as T4, is included in Microsoft Visual Studio and is a code generation engine. The template parses an input file with a .tt file extension and transforms it into an output file, such as C# code. We will explore this and T4MVC. It helps make your MVC code more maintainable and gives you IntelliSense by generating constants for View Name, controller actions, and even additional route parameters.
Let’s watch this all this come together in the video!
Original content from Robert Evans; posted by MSPFE Editor Arvind Shyamsundar