T4MVC 2.6.20, and upcoming T4MVC talk at MvcConf
I just pushed T4MVC out to the MvcContrib CodePlex site. You can go to the T4MVC Home Page to get started with it.
Last time I blogged about a T4MVC release was for 2.6.13. In the mean time, I released 2.6.14 and 2.6.15, but they were minor updates so I just tweeted them. You can check out the history page to see what they changed. Now, 2.5.20 brings a more interesting new feature, so I figured I’d blog it.
New feature to easily render Partials
Update (7/20/2010) : there was a small issue with this change when multiple ascx have the same name. I just pushed a new 2.6.21 build which addresses it.
This new feature was written by Evan Nagle (who is also the author of the Chirpy add-in I discussed a few days ago). You can check out the post he wrote about it. In a nutshell, it’s about making it easier to render partial pages. e.g. suppose you have a partial page called MyUC.ascx (say in Shared) and want to render it from another page (and pass some view data). Normally, you would write something like this:
<% Html.RenderPartial("MyUC", data); %>
Here, “MyUC” is a magic string, and surely it has to go! T4MVC has always provided a way to do this:
<% Html.RenderPartial(MVC.Shared.Views.MyUC, data); %>
Basically, it uses the T4MVC generated view token to avoid using a literal string. Functional, but ugly! But now, with this new feature you can simply write:
<% Html.RenderMyUC(data); %>
Here, T4MVC generated an extension method specifically to render the partial page, making the code not only free of magic strings, but also more concise and readable.
To disable this functionality: you can turn this off by setting ExplicitHtmlHelpersForPartials to false in T4MVC.settings.t4
T4MVC talk at MvcConf this Thursday (7/22)
Update (7/30/2010) : I ended up doing a dual talk on the Razor view engine and T4MVC. It was a last minute change since we didn’t have a speaker for the Razor talk. It was a bit of a scramble to get that in, but the talk went well, and is available for all to watch here.
The other thing I wanted to discuss is the T4MVC talk that I’ll be giving at the MvcConf virtual conference. The talk will be this Thursday at 12pm Pacific (2pm Central). Check out the full schedule here. Here is the talk abstract:
Name: T4MVC – the magic string killer
Abstract: Magic strings occur frequently in MVC when referring to Controllers, Actions and Views, and lead to code that can be hard to validate and maintain. In this session, I will show you how to use T4MVC (part of MvcContrib) to almost completely obliterate those magic strings. To make this a bit different from my previous sessions on this topic, I’ll do the demos by starting with a new MVC app from scratch, instead of starting from a complete sample like NerdDinner. I’ll be running MVC2 on VS 2010, and will include discussion of new MVC features like Areas. I’ll also present a VS Add-In that can be used to automatically run T4MVC. Finally, I will discuss how T4MVC can be used with the upcoming Razor view engine.
Hopefully I’ll see you all there, at least virtually :)
Note: even though the MvcConf site says that the conference is Sold Out, Eric is trying to find a way to stream it more globally (e.g. via ustream). Check the MvcConf site for updates on this.