Handling content in a Haml template
October 11th, 2007
I get asked this a lot about StaticMatic & Haml: Structured templates are great for HTML markup, but what about the actual content of pages?
As StaticMatic is used to manage static sites, you'll quite often have your page's content in a Haml template. While Haml works great for logical HTML markup, it can be a bit cumbersome when working with actual content:
%p
This is a paragraph of text with a
= link "website link", "http://www.stephenbartholomew.co.uk"
in the middle.
%p
It's even worse when the link is at the
= link "end", "http://www.stephenbartholomew.co.uk"
\.
Thankfully, there is a simple solution in the form of filters:
:markdown
This is a paragraph of text with a [link](http://www.stephenbartholomew.co.uk) in the middle.
It's pretty great [now](http://www.stephenbartholomew.co.uk).
This can be used in any Haml templates - it's not specific to StaticMatic. It is however more apparent :0)
Haml has a number of different filters available including plain text, ruby, redcloth and textile - check out the docs for more information.

Sorry, comments are closed for this article.