HAML Rendering for Sitecore


November 26, 2008 by Alistair Deneys

I first heard about Haml (XHTML Abstraction Markup Language) early this year on Alexey’s blog. At first I thought “What’s the point?”. After all, HTML is easy to understand and is itself a markup language. Why do I need a markup language for a markup language? But when you start writing in this higher level language everything starts to zen.

I have started to become a fan of significant whitespace used to both indent code properly and define code blocks. I always indent my code correctly and it annoys me when I come across someone else’s code when they haven’t. One problem with code or markup which is not indented correctly is that when you’re reading the code, you generally read the indentation rather than the code block closing tags. For example, in the following example it is quite easy to miss the closing tag.

<div class="myclass"><div id="nav">
    <li><a href="somelink.aspx">Link</a></li>

Just because the second div on the top line wasn’t on a line of it’s own, it’s very easy to miss and screw up your markup. Yes, Visual Studio helps a great deal with making sure your tags are closed, but what if you’re not using Visual Studio? What if you’re using the Developer Centre in the Sitecore desktop?

So I’ve written a Haml rendering for Sitecore to allow you to write your renderings in Haml. You can download version 1.0 from my website http://users.tpg.com.au/adeneys/sitecoreHamlRendering.html.

I’m hoping to put this into Sitecore shared source along side my other Sitecore tweaks so everyone can easily access the module and code and also help to enhance the module. Version 1.0 is functional, but I eventually want to have the Haml rendering available in the Developer Centre as a rendering option along side XSLT renderings.


3 thoughts on “HAML Rendering for Sitecore

  1. Lars Nielsen says:

    Hey Alistair,


  2. So very cool – makes me wish I was making Sitecore websites again.

    Have you considered more traditional Sitecore model, i.e. creating a new item under /layouts/renderings for each haml file you want to render, instead of specifying the file and codebeside as parameters?

  3. adeneys says:

    Thanks Guys,
    Yes Alexey, that’s the end goal. But I’ll focus on that after the current shared source module I’m working on has made release 1.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s


The views expressed on this blog are solely my own and do not necessarily reflect the views of my employer.
%d bloggers like this: