Posted

11 January 2008 @ 12pm

 

Web site development with StaticMatic

StaticMatic is a small framework for producing static web sites. It is built on top of a number of Ruby gems such as Haml and makes it possible to create totally static sites using Ruby.

I have spent a bit of time playing with StaticMatic and thought I would share some of the things I have learnt just in case anyone else has the same questions as I did.

Haml Syntax Highlighting

First off I use TextMate for editing. In order to make more sense of the the Haml markup which I was totally new to, I found this page with a link to a svn repository where you can download a TextMate bundle for Haml: Installing the Haml TextMate bundle. The only difference I had with the instructions was that I had to create a bundles directory which is no big deal. After that I switched TextMate’s language association option (located at the bottom of the window) to Ruby Haml and everything was great. I also found that the Blackboard theme worked quite will with it.

Setting up Helpers

As StaicMatic is based in part on Ruby on Rails there is the ability to define helper functions. There is even a page on the StaticMatic website where developers can upload there own for others to use.

The problem I had was that I could not find out how to set up a helper function in words of one syllable in the documentation and had to piece it together from a few different sources.

When you create your StaticMatic site it will make an empty directory called helpers, but thats it. In order to add a helper function to your site you need to create a file in this directory called application_helper.rb (think rails). In this add the module definition:


module ApplicationHelper
end

Add any function you like to this module and it will be available to you from all haml files simply buy using:


= function_name(params)

Using Partials

This is pretty strait forward but may catch some out (it did me). If you place a partial directly in the partials directory do not prefix the filename with an underscore or it will not be able to find the partial file.

Things to look out for

I had a lot of problems with tab characters in my Haml files. This is very annoying as the page will not display and the error message from the terminal is not useful at all. The best way I found to overcome it was to use soft tabs, 2 characters wide and if I pasted in any code to always manually re-indent it. This is a pain I know, but so is bug hunting an invisible bug for hours.

Hope this is of some help to some one, below is a list of the web pages I have found useful.

 

No Comments Yet

There are no comments yet. You could be the first!

Leave a Comment