Directly serve HAML files as HTML in Apache

424 views
Skip to first unread message

Ollie Saunders

unread,
Aug 15, 2008, 5:32:47 PM8/15/08
to ha...@googlegroups.com
Think of this as a sysadmin contribution.

I wanted to do get some HTML pages up quickly to test out safariwatir
(automated web testing library) but these days I can't stand to write
HTML when HAML is around so I added a few lines to my httpd.conf:

# HAML support
LoadModule ext_filter_module modules/mod_ext_filter.so # may not be
necessary for you
AddType text/haml .haml
ExtFilterDefine HAML mode=output cmd=/opt/local/bin/haml
intype=text/haml outtype=text/html
DirectoryIndex index.php index.haml index.html index.htm # optional

Adjust cmd under ExtFilterDefine to point to the HAML command on your
system. I believe it has to be absolute. You can use the "which"
command to tell you where it is residing.

Now you can stick files ending in .haml under any DocumentRoot they
will be processed by HAML and text/html will be sent to the client!
It's not too fast though, a process has to be forked for each request
so this is best used for prototyping type situations.

Hope this helps someone.

Ollie

Nathan Weizenbaum

unread,
Aug 15, 2008, 11:26:10 PM8/15/08
to ha...@googlegroups.com
Niiice.

Mike Ferrier

unread,
Aug 17, 2008, 12:47:19 AM8/17/08
to Haml
Sweet! Nice work Ollie.

On Aug 15, 5:32 pm, "Ollie Saunders" <oliver.saund...@gmail.com>
wrote:

Evgeny

unread,
Aug 17, 2008, 8:06:33 AM8/17/08
to ha...@googlegroups.com
This reminds me that I wrote a script to generate html from haml, and cache them.
Don't know if it will work unchanged with the latest version, but it's a nice solution for people looking to have prototype haml files generate html on the fly (using apache).

http://blog.kesor.net/2007/07/30/haml-caching-cgi/

It's more than a year old, as you can see ...

Nazmul Hassan

unread,
Oct 9, 2008, 8:27:29 AM10/9/08
to Haml
amazing.

On Aug 15, 5:32 pm, "Ollie Saunders" <oliver.saund...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages