I've been searching on SO & Google for a breakdown of the various View Engines available for ASP.NET MVC, but haven't found much more than simple high-level descriptions of what a view engine is.
I'm not necessarily looking for "best" or "fastest" but rather some real world comparisons of advantages / disadvantages of the major players (e.g. the default WebFormViewEngine, MvcContrib View Engines, etc.) for various situations. I think this would be really helpful in determining if switching from the default engine would be advantageous for a given project or development group.
Has anyone encountered such a comparison?
Check this SharpDOM . This is a c# 4.0 internal dsl for generating html and also asp.net mvc view engine.
I like ndjango. It is very easy to use and very flexible. You can easily extend view functionality with custom tags and filters. I think that "greatly tied to F#" is rather advantage than disadvantage.
ASP.NET MVC View Engines (Community Wiki)
Since a comprehensive list does not appear to exist, let's start one here on SO. This can be of great value to the ASP.NET MVC community if people add their experience (esp. anyone who contributed to one of these). Anything implementing
IViewEngine
(e.g.VirtualPathProviderViewEngine
) is fair game here. Just alphabetize new View Engines (leaving WebFormViewEngine and Razor at the top), and try to be objective in comparisons.System.Web.Mvc.WebFormViewEngine
Design Goals:
Pros:
Cons:
Example:
System.Web.Razor
Design Goals:
Pros:
Cons:
No documented API, http://msdn.microsoft.com/en-us/library/system.web.razor.aspxCon Example #1 (notice the placement of "string[]..."):
Bellevue
Design goals:
Brail
Design Goals:
Pros:
Cons:
Example:
Hasic
Pros:
Cons:
Example:
NDjango
Design Goals:
Pros:
WebFormViewEngine
NHaml
Design Goals:
Pros:
Cons:
Example:
NVelocityViewEngine (MvcContrib)
Design Goals:
Pros:
Cons:
Example:
SharpTiles
Design Goals:
Pros:
Cons:
Example:
Spark View Engine
Design Goals:
Pros:
Cons:
Example:
StringTemplate View Engine MVC
Design Goals:
Pros:
Cons:
Wing Beats
Pros:
Cons:
XsltViewEngine (MvcContrib)
Design Goals:
Pros:
Cons:
I know this doesn't really answer your question, but different View Engines have different purposes. The Spark View Engine, for example, aims to rid your views of "tag soup" by trying to make everything fluent and readable.
Your best bet would be to just look at some implementations. If it looks appealing to the intent of your solution, try it out. You can mix and match view engines in MVC, so it shouldn't be an issue if you decide to not go with a specific engine.
My current choice is Razor. It is very clean and easy to read and keeps the view pages very easy to maintain. There is also intellisense support which is really great. ALos, when used with web helpers it is really powerful too.
To provide a simple sample:
And there you have it. That is very clean and easy to read. Granted, that's a simple example but even on complex pages and forms it is still very easy to read and understand.
As for the cons? Well so far (I'm new to this) when using some of the helpers for forms there is a lack of support for adding a CSS class reference which is a little annoying.
Thanks Nathj07
I think this list should also include samples of each view engine so users can get a flavour of each without having to visit every website.
Pictures say a thousand words and markup samples are like screenshots for view engines :) So here's one from my favourite Spark View Engine