T4 Templates

Preview:

DESCRIPTION

An introduction to T4 templates

Citation preview

T4

Overture• Level 01-01-02• Interactive

• On the Menu– What it is?– Demo– Alternatives– Learning’s

TLA• What does T4 stand for?• Text Template Transformation Toolkit

Three Two Letter Acronym

Why do we need it?• Cause developers are expensive and Xbox games

are fun

History

2005 Shipped out of band platform

2008 Shipped platform with Visual Studio

2010MAJOR enhancements to platformSomething is missing here…

A word of warning…• Out of the box tooling DOES NOT EXIST– It’s notepad + command line basically

• 3rd parties can make the pain go away– I use the free stuff from Tangible & T4 Toolbox– You will too, accept that and move on

Is this thing used?• ASP.MVC uses T4 templates for views and controllers• DSL tools in VS 2010 use it– BizTalk– Architecture Tools

• 3rd Party uses like LINQ to SQL replacement

High Level Plan

Template Code OutputT4 toolkit .NET Framework

C#

VBHTML

XAMLCSV

DEMOSLIKE THE MOON LANDING DEMOS TAKE LOTS OF PREPARATION, LEARNING NEW SKILLS AND MOSTLY FAKING IT

What haven’t you seen?

• Build integration• Pre-processed Templates

Alternatives• CodeDOM– Part of .NET– Used internally by T4– More powerful– Harder to learn– Ideally for language scenarios

Alternatives• CodeSmith– Third Party– $$$– More rugged tooling, debugging features

Alternatives• NVelocity– Port of Java’s Jakata Velocity– Free– Wildly different syntax

Alternatives• Hire a monkey

• Maybe this is why you were hired…

Help?

Learning's• Search for T4 AND Visual Studio Text Template • Use the Tangible T4 editor• Use the T4 Toolkit• Make use of scratch applications in prototyping• For use within Visual Studio

QUESTIONS

robertm@bbd.co.zawww.sadev.co.za@rmaclean

Recommended