I'm excited to see Kevin's work on template plugins,
and that the TurboGears plugin system is fully extracted into a
generic plugin for templates. I think this will be an easy ad hoc
standard to start supporting elsewhere. It should encompass all the
"normal" templating languages that just take a bunch of variables
(something like meld3
probably won't work with this, though). I doubt code can be very well
neutral with respect to the template language it is feeding. Kid and
Cheetah can have arbitrary Python to munge the data in them. ZPT can
have Python expressions, but not statements or functions. Django and
ClearSilver need data structures that require very little processing
in the template, as they don't have generic expressions at all. So
you can't exactly be neutral. But still this is an important step
forward.
One of the big issues in making little apps
is how to make them fit into a larger site. It's mostly fine if the
internals of the pages are written by different templating languages.
Standard conventions for CSS classes would be a tremendous boon, but a
little sloppiness isn't that big a deal. But you still need an
application that is well-wrapped in some template for your site. Each
application may have a way to give a site template, but if they are
all using different templating languages that means a lot of
duplication. (And even if they are using the same templating
language, some standard way to override templates is still needed, or
else you have a mess of things to manage).
So... what to do...
I like HTTP, so I naturally go that direction for interoperability.
Server-side includes provide a
simple, relatively language-neutral way to handle templating. But
they work textually, not based on markup, and there's lots of issues
with the typical implementations. XSL applies well here, of course.
I haven't used XSL for years, but my brief experiments with it left me
so disheartened I simply can't imagine it being useful for templating.
But more primitive templating is quite possible. One of the
interesting ideas I've seen (and I'm sure there's others -- if you
have one, then do comment) is HTML overlays.
This can be implemented on the client-side in Javascript, but of
course it could be implemented as a filter easily enough as well.
Then applications would each take a site_template configuration
parameter, and maybe a Javascript parameter if client-side overlays
were going to be used (presumably any filter would simply notice the
overlay and implement it). Then the application would put this in the
head:
<link rel="overlay" type="text/x-im-not-sure"
href="/configured-template-location" />
Actually I now think the type should be configurable too, allowing for
other kinds of templates than just this implementation of overlays. Also
overlays don't seem to have a way to pull in content, they only allow content
to be pushed into them.
Obviously the Javascript can be applied to any site. A server-side
filter could also be easily(ish) written in C as an Apache filter, or
as libraries in a variety of frameworks and languages.