Introducing T4 Templates

5,415 views
5,287 views

Published on

Presented at DevEvening Melbourne # 1.

Published in: Technology, Business
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,415
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
76
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide
  • C:Program FilesMicrosoft Visual Studio 9.0Common7IDEItemTemplatesCSharpWebMVCCodeTemplates
  • Introducing T4 Templates

    1. 1. Introducing T4 Templates<br />Chris Melinn<br />
    2. 2. Agenda<br />This presentation will provide a short overview of T4. We will learn the basics of creating a template and then see a few examples of how T4 is used by others.<br />
    3. 3. The Basics<br />
    4. 4. What is T4?<br />T4 = <br />Text<br />Template<br />Transformation<br />Toolkit<br />
    5. 5. What is T4?<br />Generates any textual format <br />Common examples:<br /><ul><li>Code (C#, VB, etc)
    6. 6. SQL
    7. 7. XML</li></li></ul><li>But…<br />Editing T4 sucks *<br />* with the default Visual Studio setup<br />
    8. 8. The Default Visual Studio Editor<br />
    9. 9. Fortunately, there is a solution…<br />Free Visual T4 Editor<br />Community Edition<br />from Clarius Consulting<br />
    10. 10. The Visual T4 Editor (inside Visual Studio)<br />
    11. 11. DEMO #1<br />Creating Templates<br />
    12. 12. How it works<br />T4 engine performs two steps to generate output from a template:<br />Source: Oleg Sych http://www.olegsych.com/<br />
    13. 13. Applications of T4<br />Examples of T4 in the wild<br />
    14. 14. “If you’re going to do something twice or more, manually, in your company, generate it.”<br />~ Scott Hanselman<br />
    15. 15. T4 can be used to generate…<br />
    16. 16. DEMO #2<br />ASP.NET MVC CodeTemplates<br />
    17. 17. DEMO #3<br />T4CSS<br />
    18. 18. Summary<br />For more information…<br />
    19. 19. Resources<br />Oleg Sych’sblog is the best collection of T4 resources I have found anywhere<br />http://www.olegsych.com/<br />His CodePlex project, T4 Toolbox, contains several ready-to-use code generation templates and other supporting extensions.<br />http://www.codeplex.com/t4toolbox<br />
    20. 20. Editing Tools<br />Visual T4 Editor from Clarius Consulting<br />http://www.visualt4.com/<br />Tangible T4 Editor by Tangible Engineering<br />http://t4-editor.tangible-engineering.com/T4-Editor-Visual-T4-Editing.html<br />
    21. 21. Other Examples of T4<br />T4CSS<br />http://haacked.com/archive/2009/12/02/t4-template-for-less-css.aspx<br />T4MVC: Creates strongly typed helpers to eliminate your “magic strings”<br />http://aspnet.codeplex.com/wikipage?title=T4MVC<br />Generate WPF and Silverlight Dependency Properties using T4<br />http://www.codeproject.com/KB/WPF/DependencyPropertyCodeGen.aspx<br />
    22. 22. Contact Me<br />Blog: http://chrismelinn.wordpress.com<br />Twitter: http://twitter.com/ChrisMelinn<br />

    ×