NVelocity over Spark

Ever since I started to build web applications using Castle Monorail, I used NVelocity as view engine.

I know many think is not powerful enough and that there are view engines better than NV. Still, for our projects, NV was just enough.

For Storingen project I decided to user Spark v1.0, a new view engine built initially for MS-MVC. Now that the project was launched to production, I though I’d share some thoughts on Spark vs. NVelocity.

1. For a view engine having the slogan “less is more”, Spark is way too verbose.

Compare this:

Spark:

<test if="PropertyBag['actionResult'] !=null">
    <p style="color:red"> ${PropertyBag['actionResult']}</p>
</test>

NV:

#if ($actionResult)
    <p style="color:ff0000"> $actionResult</p>
#end

2. Try to debug this:

Dynamic view compilation failed.

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\my.project\f6ea7153\3708dd9104e947bd8207471079fe1268-1.cs(151,138):

error CS0103: The name ‘pipeLocations’ does not exist in the current context

True, Spark too throws the error + code line in the face in some situations, but I didn’t figured out which ones.

3. Spark was built with MS MVC in mind thus its integration with Monorail is not entirely functional.

For example, ${Form.DisableValidation()} does not work.

4. Another annoying thing is that I have to declare the <viewdata Cities=”List<Storingen.Model.Cities>/> although I have already added the Cities in the PropertyBag in the controller.

The only advantage with Spark is that I can use C# code directly in views while in NV I had to build some helpers.

In Spark though, I have to declare the variables that I need in the view: <var Format=new FormatHelper()/>.

In the end, I have to admit that switching from NV to Spark was quite a shock for me…

P.S. for the next projects I’m heading to AspView, then for Brail… or the other way around..