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:


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


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

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..


4 thoughts on “NVelocity over Spark

  1. Pingback: ASP.NET MVC Archived Blog Posts, Page 1
  2. Pingback: DotNetShoutout
  3. This is less verbose:
    I don’t have experience with MonoRail; but I think this will also work:
    Now, this IS less 😉 especially because now we have 1 line and it’s HTML only. And if you declare you actionResult in viewdata (or use strongly-typed models) you can avoid even PropertyBag[].

    The fact that you have to declare ViewData / PropertyBag variables can be annoying… if you don’t use “single ViewModel” (strongly typed models) and try to use Cities properties. However I think this should work even if you don’t declare it: ${Cities}. Of course if=”Cities.Empty()” won’t work since it is C# code, not property evaluation.

    In general, I think you just tried to use Spark in a way that you used to go with NVelocity. Spark really does more with less code; and has lots of small tweaks like conditional attributes (class=”first?{productIsFirst}”) or null handling $!{} that helps to achieve that.

    Also, Spark gives you macros – inline mini-partials that helps you to build HTML helpers by writing HTML, not C# code.

    As for Form.DisableValidation(), it doesn’t return value but you try to capture its output vlaue; use # Form.DisableValidation() (that is, inline code instead of property capture) and it will work.

    As a summary, I think you should either give Spark another try, or just admit that it’s not as bad as you thought.

  4. Oops, no <s and >s… Here’s the shortest version:

    <p style=”color:red” if=”PropertyBag[‘actionResult’] !=null”> ${actionResult}</p>

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s