Sitecore CMS and everything related RSS 2.0
 Friday, January 25, 2008

“Haml is a markup language that‘s used to cleanly and simply describe the XHTML of any web document, without the use of inline code. Haml functions as a replacement for inline page templating systems such as PHP, ERB, and ASP. However, Haml avoids the need for explicitly coding XHTML into the template, because it is actually an abstract description of the XHTML, with some code to generate dynamic content.”

Basically Haml is a domain specific language for XHTML. Unlike Velocity, which can be used to output any text data, Haml focuses entirely on xhtml output — and does it well.

Instead of:

  
<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" }) %>

You can do this:

%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" })

(It does look like python, doesn't it?)

Do we need it?

Andrew Peters has created a NHaml, .NET port of Haml made as an alternative view engine for ASP.NET MVC.

I assume it wouldn't be too hard to take it apart and create a Haml rendering type for Sitecore as a downloadable extension. Is this something you find interesting? I love its clarity and wrist-friendliness, and it should be much easier to type online using Developer Center or even Content Editor.

The downside is that you'd lose intellisense in visual studio, but personally I'm much more annoyed by visual studio trying to format my <% %> code the way it thinks i like it. And yes, it's yet another templating engine.

 

* Haml reference

Friday, January 25, 2008 5:52:07 PM (FLE Standard Time, UTC+02:00)  #    Comments [0]
Sitecore | Web development
Comments are closed.
Archive
<March 2010>
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910
Blogroll
 Alex de Groot
Few words about SiteCore from Holland
 Alexander Shyba
Sitecore Support
 Anders Dreyer
Anders Dreyer on Sitecore Development
 Jakob Christensen
Sitecore Core Development
 Lars Fløe Nielsen
Lars's ramblings about development and business processes
 Ole Thrane
Sitecore API
 Runi Thomsen
Runi Thomsen Sitecore Toughts
 The Sitecore Experience
The Sitecore Experience
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010
Alexey Rusakov
Sign In
Statistics
Total Posts: 211
This Year: 0
This Month: 0
This Week: 0
Comments: 0
Themes
Pick a theme:
All Content © 2010, Alexey Rusakov
DasBlog theme 'Business' created by Christoph De Baene (delarou)