T4 Text Template Transformation engine

by Kevin Bosch 13. August 2010 20:07

I have just found out about the existence of T4 generator today. Is a very simple yet powerful Template based text generation engine. It uses very familiar asp.net syntax <# #> Its simplicity is its strength. There is a good site on the T4 Text Template Transformation Toolkit by Oleg Sych

T4 Text Transformation Engine

If you have not tried it out you should give it a go.

Looking at generation I am wondering why they have stopped at the generation part. MVC pattern is screaming out to be implemented as part of the generation. I know the MVC model is designed to be implement as part of user interface design. However I think there is a good fit here. The Template generation is clearly the rendering of the view. The model will be the domain specific model such as the data schema when implementing the crud model on top of a relational schema. The controller is responsible for populating the model based on the instance required by the view. As such the part which is screaming out to be specialized is the controller.

Consider the power of the following example which from what i can tell is not possible

        <@# template language="C#" Inherits="GeneratedTextTransformation<MyHelloWorld>#> 
        <# Write(Model.HelloWorld); #>

There is still a bit of learning to do, T4 is looking promising

Tags:

DataTable

Comments


August 22. 2010 03:18
cadillac
I don't know if I am any smarter but I enjoyed reading your post - Thank You


August 27. 2010 15:10
MilfVideos
Hey, very nice blog! Beautiful and Amazing. I will bookmark your blog and take the feeds also


August 28. 2010 09:25
kevinbosch
Hi Greg

T4 is built into VS.NET 2008.  Create a file called demo.tt  drop the following code in

<#@ template language=“C#” #>
Hello <# Write(”World!”) #>

Then it should create a file called demo.cs with Hello World!  With in.  
if you follow the link by Oleg Sych in the post he shows how it works.




September 5. 2010 17:34
Weddings Mount Tamborine
Impressive business, I like how you think out of the box.

Comments are closed

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar
Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2012 Code Associate