Browse by Tags
All Tags »
T4 (
RSS)
T4MVC has always struggled with finding the right way of running automatically when you build. Being a T4 template in your project, by default it just runs when you save it. This is not great, because you really want it to rerun whenever you make a change that affects it: e.g. new controller action, new static file, … So I had come up with a pretty crazy workaround (the AlwaysKeepTemplateDirty flag), described in details in this previous post (under “ The T4 file automatically runs whenever you build ”). It’s a pretty hacky technique, which mostly works but has some nasty quirks: You need to open and save it once to start the save ‘cycle’ You need to leave it open It’s always marked as dirty, which is an annoyance. The...
To get the latest build of T4MVC: Go to MvcContrib T4MVC page on CodePlex A few weeks back, we announced (mostly on Twitter) that T4MVC was moving into the MvcContrib Codeplex project. I didn’t say much about it at the time because there wasn’t a whole lot to say yet, in the sense that the move had not actually happened. MvcContrib was transitioning from github to Mercurial, and since I wasn’t familiar with either one, I figured I’d wait for that and only have to learn Mercurial. So to make it short, all of this has finally happen, and we can now say that T4MVC is officially part of MvcContrib! Many thanks to Eric Hexter and Jeremy Skinner for helping make this possible. So what difference does it make for it...
To get the latest build of T4MVC: Go to T4MVC page on CodePlex One of MVC 2's major new features is the support for breaking up a large application into "Areas". This works by following a structure that looks like: Root folder Models Views Controllers Areas NerdDinner Models Views Controllers Blog Models Views Controllers So basically you still have your top level Models/Views/Controllers folders, and in addition to that you can have an arbitrary number of “Areas”, each having their own set of Models/Views/Controllers folders. Starting with MVC 2.6, T4MVC lets you use areas in much the same way it lets you access top level items. e.g. you can now write: <%= Html.ActionLink("Delete Dinner", MVC.NerdDinner...
Up until now, most things related to T4MVC were happening through my various blog posts about it. And while that was sort of working ok for a while, it was also less than ideal for a couple reasons. First, there was no single place to go to in order to get information about it. You’d basically have to go through the various posts that describe the various features as they were added. And as the number of posts grew, so did the pain involved in doing that. The second issue is that there was no good place to discuss it, ask questions and report issues. So all of those things were mostly just happening organically as comments in my various posts, which really doesn’t work so well. Blog Post comments don’t support threading...
To get the latest build of T4MVC: Go to download page on CodePlex MVC 2 Beta introduces two nice helpers called Html.RenderAction and Html.Action. Phil Haack described them in detail on his blog , so you may want to read through that before reading this post. Basically, they’re two additional methods that follow the standard MVC pattern of passing the controller name and action name as literal strings, and the action parameters as anonymous objects. e.g. Copying from Phil’s example, if you have an Action like this: public ActionResult Menu(MenuOptions options) { return PartialView(options); } You can write this in your View: <%= Html.Action("Menu", new { options = new MenuOptions { Width=400, Height=500} })%>...
To get the latest build of T4MVC: Go to download page on CodePlex T4MVC build 2.5.00 brings a couple of fun new features that I’ll describe in this post. I can’t take too much credit for them as they came from users who suggested them to me, and helped out getting the code going. Support for multiple output files Up until now, T4MVC.tt has always generated a single file, which is the T4MVC.cs that you see get nested under it in VS. And normally, this is the way T4 templates work: they just generate one file. But last week I got an email from Stuart Leeks who pointed me to a new blog post from Damien Guard that describes a nice way to get around this description. All of Damien’s logic is very nicely encapsulated...
To get the latest build of T4MVC: Go to download page on CodePlex Though I haven’t blogged for a while about T4MVC, I’ve been making a few minor updates and only sent notification via Twitter. Now, I have a few things that are worth discussing in a little more detail. Note that you can see the complete list of changes from version to version in the readme.txt file that comes with it. BTW, I used to have all this revision information directly in the .tt file, but it was getting a little long so I moved it to the readme. The changes described below were added between version 2.4.00 and 2.4.04. MVC 2 Preview 2 support The most interesting things to many people is that I just made a fix to allow T4MVC to work on MVC...
To get the latest build of T4MVC: Go to download page on CodePlex This post is a continuation of various previous posts on the T4MVC template for ASP.NET MVC: A new and improved ASP.NET MVC T4 template The MVC T4 template is now up on CodePlex T4MVC 2.2 update: Routing, Forms, DI container, fixes I last blogged about version 2.2, and there have been a number of changes since that (you can get the full history at the top of the T4MVC.tt file). This post describes some of those changes. T4MVC now uses a separate settings file Previously, if you wanted to customize T4MVC, you’d have to change T4MVC.tt directly. This is fine until you want to grab the next build, and have to hand merge the changes. Instead, it is now using a separate...
T4 templates have proven to be useful is a whole range of scenarios, and more and more developers are finding interesting things to do with them. For the most part, all those scenarios fall under two very distinct categories: “support code” versus one-time generation. Unlike my previous post on CodeDom vs. T4 , here we’re not talking about making a choice between two competing technologies, but simply about using T4 in the way that makes sense for a given scenario. Let’s start with a brief description of the two usage patterns: Support code : here, a T4 template generates a file that you rarely need to look at, and you should never modify. Instead, it contains “support code” that you can code against. A great example of this...
Last month , I wrote a number of posts on using T4 templates to get strong typing in ASP.NET MVC applications. The result is the T4MVC template available on CodePlex . This template has been pretty popular with many MVC users, and I received a huge amount of feedback on improving it. Most of it has been integrated into the CodePlex version (see the extensive History section in the TT file!). While T4MVC is only useful to MVC applications, someone suggested that ASP.NET WebForms applications could also benefit from some strong typing, so I put together a little T4 template that does some of that. Unlike T4MVC which tries to cover a whole range of MVC scenarios (relating to Controllers, Actions and Views), this template just does one thing: it...
More Posts
Next page »