Haml for MonoRail

May 16, 2008 at 12:20 AMAndre Loker

It would be soooo cool if there was an HAML based view engine for MonoRail. For ASP.NET MVC one is already being made.

The following example is shamelessly ripped off of Andrew Peter's site:

ASPX:

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" 
    CodeBehind="List.aspx" Inherits="MvcApplication5.Views.Products.List" Title="Products" %>
<asp:Content ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
  <h2><%= ViewData.CategoryName %></h2>
  <ul>
    <% foreach (var product in ViewData.Products) { %>
      <li>
        <%= product.ProductName %> 
        <div class="editlink">
          (<%= Html.ActionLink("Edit", new { Action="Edit", ID=product.ProductID })%>)
        </div>
      </li>
    <% } %>
  </ul>
  <%= Html.ActionLink("Add New Product", new { Action="New" }) %>
</asp:Content>

NHAML:

%h2= ViewData.CategoryName
%ul
  - foreach (var product in ViewData.Products)
    %li
      = product.ProductName 
      .editlink
        = Html.ActionLink("Edit", new { Action="Edit", ID=product.ProductID })
= Html.ActionLink("Add New Product", new { Action="New" })

MonoRail deserves this, too!

Update 6/6/2008: cool, there's an upcoming NHAML view engine for MonoRail

Posted in: Castle

Tags: , ,

Pingbacks and trackbacks (1)+