codeflood logo

HAML Rendering for Sitecore

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">
  <ul>
    <li><a href="somelink.aspx">Link</a></li>
  </ul>
</div>

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://www.codeflood.net/files/Haml Rendering-1.0.zip.

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.

Comments

Hey Alistair,
Genious!

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?

Alistair Deneys

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 comment

All fields are required.