I just read this blog post on Razor Templating in ASP.NET MVC 3.
Put simply, i just dont get it!
That is, i don't see why we need this (fairly) complicated code to achieve what can be done IMO easier (and neater) with @RenderPartial
?
Here's what i don't like:
- The template is stored as a
Func<T,HelperResult>
delegate? - That template delegate is persisted in the Controller ViewData (e.g HttpContext.Current.Items)
The only "benefit" i read from that blog is that a seperate file isn't required for templating, meaning you don't need to re-compile etc.
But i don't see that as a valid argument. Extra files are fine as long as the solution organization isn't compromised.
I prefer using @RenderPartial
, as i can keep my markup seperate from the master view, and i can render this both inline (render time) and with jQuery (e.g AJAX event).
Maybe i'm missing something here, but can anyone give some reasons why we should choose Razor Templating over RenderPartial to create re-usable content?