Zack asked for website meta languages for redoing his homepage.
Well, I redid
my homepage last february,
using XML and XSLT. A monster XSLT stylesheet, because I wanted to keep my
template outside of the stylesheet.
I can not recommend XSLT. Using it for templating is quite messy. XSLT is okay
if you want to transform one representation of the data to another; it's not
if you want to add a lot of surrounding markup and things like a sitemap and
similar navigation tools. This is next to impossible in pure XSLT, it gets
better once you have some extensions (dubbed EXSLT, and supported by pretty
much any xslt processor) or maybe with XSLT2. String manipulation is also a
pain (at least with XSLT1); I gave up on generating a nice "last modified" date
from my subversion tag. Supposedly XSLT2 has some functions that could make
this easier (i.e. for parsing and printing datetime information), but the
common approach with XSLT is to only supply the required minimum of function
you need, and I'm not aware of an easy way to add custom functions, not to
mention any large standard library that can efficiently be used (which is the
true strength of Java, Python and C#, that they bring a huge collection of
pre-written ready-to-use code with them). Of course there are some efforts to
write XSLT libraries (especially for XSLT2), and this aforementioned
EXSLT is some kind of standard library that
even might be efficiently implemented in some interpreters - you can't rely
on it to be there and to just work. XSLT isn't useless, but when it comes to
presenting data to humans or writing clean, compact code it's not satisfactory
at all.
I'd give you my Makefile and XSLT file, if they weren't that messy... too many
features; I'm generating two languages, a partially expanded navigation menu,
etc. - my XSLT is 10k, my sitemap currently 4.5k, the template file is 5k.
Anyway. Half a year ago, my favourite templating language was
KID templating. I used it for some
small projects such as my
DNSoupdate tool
to edit DNS zones via the DNS protocol (requires a nameserver such as bind
which has support for DNS update, uses encryption). It was a perfect match for
such tiny pages, but I'm no longer that convinced I still like it for larger
projects.
What's good about Kid: XML templating language, Python based, easy to use in
whichever way you want by writing a few lines of python (i.e. easy to write a
Makefile to generate a static version of you homepage)
What's not good about Kid: only works with a Python interpreter. I'd prefer to
have a templating language that can be used from multiple languages. However
the Kid syntax relies on Python, which is really bad. Also I'd prefer to have
some component-render model for more complex websites. The current setup is
IMHO okay if you have one default layout and one content layout; but if you
have multiple components that could be combined differently on the pages, it
gets too messy. With my turbogears experiments, Kid was also not very
performant (but that might as well be Turbogears fault).
Right now, I'd probably still go with Kid. But I've been having a look at JSP
2.1, and JSF / Facelets in particular. There are some things about facelets
that I really like (for example, that they use a proper XML syntax, instead of
this bastardized almost-XML that JSP usually (ab-)uses). There is also some
stuff that I don't like (e.g. the massive overengineering of everything
surrounding it), and I have no idea how easy it will be to generate static
pages in a scripted fashion, i.e. using it without a real webserver. Or I
might just write it all in python, which is a nice language for manipulating
XML, usually.
Please don't just send me an email with your favourite templating engine. Like
zack, I'm only interested in XML-based templating engines, which does not
apply to most templating solutions out there. Clearsilver for example is
another bastardization of XML. I'm aware of TAL/METAL, and find them quite
interesting, but they were also not having this kind of componentization that
I'm usually thinking in.
[Update: some people have pointed me to Genshi, which is mostly Kid compatible.
However, it still has mostly the same problems, e.g. the templates being not
reusable in other languages than python, and that certain constructs are a
pain to do (e.g. the page_specific_css recipe with more than one css file).
Others have pointed me to smarty, but it's string-based and doesn't ensure
valid XML output. (Which is very useful for e.g. generating atom or rss output)
For example this is probably valid in smarty:
if 0 <b> /if </b> - allowing errors is bad. Oh, and
smarty is PHP, which is broken by design, a no-go. The best match to my ideas
so far is
XML::Template (for
Perl, Python, Ruby, PHP) which is pretty close to what I've been doing manually
when not using a templating solution. I don't know yet how well it handles
recursion - I need recursive templates for the navigation menu on my homepage.]