Hamlize Your Site - Without Rails!
Since I first started contributing to Haml, I’ve made sure to keep it separate from Rails as much as possible. I wanted Haml to be able to run just fine without ActionPack. This meant refraining from the use of any Rails helpers or extensions, as well as some fancy footwork to make the Haml/Rails integration seamless when Rails is being used, and nonexistent when it’s not.
I also made sure to expose a simple programmatic interface to Haml, so developers could integrate it into their own projects. The syntax was similar to that of other Ruby text filters like RedCloth1:
Haml::Engine.new("%p Foobar").render #=> <p>Foobar</p>
This allowed for the easy creation of various bits of code using Haml. There have been hamlize rails helpers written. In the official gem, we have a haml executable that uses this to process files or standard input (I use this to Hamlize every XHTML or XML file I write). I believe several people (including myself) have independently created Radiant filters for Haml using this.
Recently, though, I’ve seen the separation of Haml and Rails and programmatic access to Haml used to much greater effect. The idea behind this project is that some sites just work better as static collections of files; Rails would be overkill. Unfortunately, Rails is necessary for using cool tools like Haml. So I guess it’s back to plain, old, WET2 and ugly XHTML, right?
As of two days ago, wrong! You see, Stephen Bartholomew has created StaticMatic, a tool for creating static websites using Haml and Sass. From the announcement:
CMS is overrated. A lot of the time, clients want us to do what we do best – well designed pages with structured, accessible and maintainable markup & styling.CMSs are often sufficient for this, but sometimes they can be restrictive and more cumbersome than just working with good ol’ source code. At the same time we want our code to be structured, DRY and flexible.
Enter StaticMatic.
I just think this is super-awesome. We’ve had requests on the Haml list for just something this sort of thing – a way to use Haml while neither building up an entire Rails project nor invoking the executable over and over again.
1 Incidentally, I use RedCloth for marking up these blog posts. Why don’t I use Haml? Haml’s very good for designating the structure of HTML, but that’s not what posts are about. Markup in posts delineates which sections of the text mean what, which isn’t the same thing as how a page is structured. For that, RedCloth is much better suited. I do use Haml for the rest of the site, though.
2 As in not DRY... get it?
About Me
make_resourceful


