I have my own template code generation system, compiling code in a separate application domain before VS2008 came out.
If you are interested, send a comment and I will send the URL.
The code for using my template engine is here , you can access it using a web browser or specify a Subversion client. Please note: the link that starts here does stop after the word, but the server side WMD renderer loses touch with the following text.
Please note that if you simply copy one file in this namespace, it will not compile on its own, it requires some things in LVK.Delegates and LVK.Scripting, namespaces raises a couple of levels from the link above. If you do not want to suck out the entire library, you will need to extract the pieces that it complains one at a time until it compiles.
There is also a binary version of the library in / LVK_3_5 / trunk / Binaries / Debug / LVK in the same repository.If you download it as easy as adding a link to it, and check the LVK.Text.Templates.TextTemplate class.
Unfortunately, I don't have examples for my library right now.
Basically, to use the template:
TextTemplate tt = new TextTemplate(); tt.Source = "... code here, check example file above ..."; tt.Compile(); String output = tt.Generate(singleObjectParameter);
Inside the template, which is basically all the code that is inserted into one method (which means that it is not as good as T4, since it can easily add methods, but you can use anonymous methods), you will have access to the object data passed to it as a parameter named data.
So, to simply display the contents of the passed parameter:
<%= data %>
To repeat this:
<% for (Int32 index = 0; index < 10; index++) { %> <%= data %> <% } %>
If you have questions, send them to my email address at lasse@vkarlsen.no.