Cockatoo Software

Ruby, Sinatra, Haml and Textile

Published on 20 May, 2010 by Keith Pitty

Ruby and Sinatra. If these two words prompt you to think of a precious stone and a famous singer, then this article is aimed at giving you an insight into the technology used to build this site. Even if you are familiar with Ruby the programming language and Sinatra the web framework, you may be interested to know how and why I used them together with other tools such as Haml and Textile.


It’s pretty safe to say that in 2010, if you aren’t taking advantage of the web to promote your business, you risk missing out on opportunities that will otherwise flow to your competitors.

When I decided to redevelop my company site, I first sketched the layout that I wanted for the site. Next, I needed to choose what tools to use to build the site.

If you’re familiar with blogging engines like Wordpress, you may be wondering why I didn’t go down that path. My answer is twofold:

  1. I wanted to have complete control over what the site could do as it evolved;
  2. Being a programmer, I naturally wanted to use my tools of choice!

Why I chose Ruby, Sinatra et al

As I said, I wanted full control over my site as well as the chance to use tools that I considered well suited for the task. So here is a little bit about the major tools I chose and why I chose them. (If you’re not familiar with some of the technical terms, don’t worry – I’m just trying to give you an idea of what tools are behind the development of this site.)


I’ve used many programming languages throughout my career but during the last few years Ruby has been my favourite. I find it to be very expressive with an elegant syntax that is not too dissimilar to English. Combined with its expressiveness, Ruby makes it easy to achieve programming tasks quickly via its dynamic nature, modularity and extensive open source library support.

To me, with a professional background in web application development dating back to 2000, Ruby became especially interesting when the Ruby on Rails framework was released as open source in 2004.

So, I chose Ruby because it’s my language of choice and I was familiar with several web frameworks built upon it.


Sinatra is a lightweight Ruby web framework that I’ve grown to enjoy for developing small sites. Amongst other redeeming features, Sinatra has a beautifully simple way of handling HTTP requests using pattern matching.

This site is never going to be huge nor be very complex so I decided that Sinatra would be better suited than it’s older cousin Rails, which I think would have been overkill.


Having chosen the language and framework, it was now time to focus on tools that made it easier to present the views, or web pages.

Haml is a templating language that significantly simplifies markup for views. As an added bonus to its elegant syntax, Haml also has several useful filters, one of which brings us to the next tool I want to talk about.


Following the principle of keeping the site as simple as possible, I decided to use Textile for writing most of the content. Textile is a simple text markup language that is commonly used in wikis and the fact that Haml has a Textile filter made it feel natural for me to use.

Other tools

Still with me? I hope you have found this article interesting so far. The astute reader may have noticed that I haven’t mentioned anything about a database, yet there is a collection of articles, like this one. Rather than store these in a database I decided to use a combination of a Haml file for the core of each news item or article together with some metadata stored in a YAML file. I have a Ruby script that generates the final Haml files that are used to present each page which either contains an article or has links to articles.

What else? One last tool I’ll mention is a Ruby library called Pony that made it very easy to send emails whenever someone sends a request or provides some feedback via the contact form. Sometime soon I’ll probably modify the site so that it sends me a direct message via SMS or Twitter as well as an email. Given the many Ruby libraries that exist, I am sure that won’t be difficult.


I could go into more depth but I think that’s about enough to give you a flavour of what tools I used and why I chose them.

To take advantage of the services that Cockatoo Software offers, contact us today to tell us about your software challenge.

Keith Pitty is the owner of Cockatoo Software Pty Limited. He has over 30 years of professional software development experience and has a passion for providing software solutions that help people. Away from computers he loves sport, especially cricket, golf and Australian Rules football.