28 Oct 2005

SiteMesh

Most of the templating I’ve done for the web has been with Tiles but lately I’ve used SiteMesh. I’m drawn to the simplicity: using it, at least the way I’ve been using it, means removing elements from pages you write rather than having to add anything special in. I’ll explain…

When I’ve used Tiles I add bits of magic to any page to make sure the right template shows up. It works, it’s powerful. The SiteMesh approach is to provide a decorator for plain pages. This makes it framework agnostic, simply taking whatever output it gets and decorating on whatever presentation mark up you want. It’s liberating writing very simple pages, and not having to sprinkle tags all over the place.

As far as I can tell, the decoration runs as a filter that parses the HTML (or whatever you’re creating) to figure out what to put where. If you’re like me, you’re maybe a bit worried about the “parsing” part. Surely that’d be slow? Somehow it’s not. I was having a dig around in a profiling tool, and I couldn’t see any interesting app slow down.

One worry is that SiteMesh hasn’t had a release since August 2004. However, it could be that the project is just moving to a new home, and I see there’s activity around a 2.3 and 3.0 release.