Using Brail View Engine with ASP.NET MVC

In my last post I started to take a look at the Brail View Engine in ASP.NET MVC.  In this post I’m going to take a quick look at some of the other details of using Brail.

Using strongly typed view

To access a variable called ‘Time’ in the ViewData we would use the following syntax:

<p>The time is now ${Time}</p>

To access a property called ‘Value’ on the ViewModel we would use the following syntax:

<p>Viewmodel's value is: ${viewData.Model.Value}</p>

Pretty neat and easy.  I would have preferred just Model.Value, but it’s close enough.


The MVC Contrib site makes no mention of how to do iterations or any type of evaluated code (that I could find).  The MonoRail site has much better documentation, although not all of it is relevant to the MVC port.  The following is a quote from the CastleProject site:

Brail supports two code separators <% %> and , I find that <% %> is usually easier to type, but allows you to have valid XML in the views, which is important for some use cases. Anything outside a or <% %> is sent to the output. ${user.Id} can be used for string interpolation.

As far as I can tell only the syntax is supported.  The following is an example of an iteration.

<?brail for element in viewData.Model.Items: 
    output "<li>${element}</li>" 
end ?>


Unfortunately this is where my journey with Brail ends.  The syntax is decent but definitely not what I’m looking for – providing clean html to allow a designer to work closely with the views.  The syntax for evaluated code is still too complex for my liking.

I had a look at some of the other view engines available and some of them show some definite promise.  More on this will follow.