Tuesday, September 6, 2005

APR-Template 0.0.1

I just cut the first release of APR-Template, my Apache Portable Runtime based templating system. Since I already wrote a perfectly good README file that explains what it is, I'll just quote it here:

APR-Template is a minimalist template library implemented on top of APR and APR-Util. It's designed to provide a lightweight templating solution that fits easily into an Apache HTTPD module or other APR based program.

The template language looks like this:

<html>
<head>
<title>[% print title %]</title>
</head>
<body>
[% if add_header %]<hr>[% end %]

<h1>[% print title %]</h1>

<ul>
[% for e in elements %]
<li>[% print e %]</li>
[% end %]
</ul>

[% if add_footer %]<hr>[% end %]
</html>

Which produces about what you'd expect. If you've used Template-Toolkit or EZT you'll find APR-Template to be similar, although the feature set is quite stripped down, so if you find yourself trying to do a whole lot in your template it's a sign that you either need to put that logic into your C code or find a different template engine.

For examples of how to use APR-Template in a program please refer to the tmpl command line tool (in src/cmdline/tmpl.c) and the mod_template_example apache module (in examples/mod_template_example).

There's a bunch of stuff I still want to do with it (see the TODO file in the tarball for details), but the current version has just enough functionality to be useful, so I decided it was a good point to cut a release. Get it while it's hot: http://electricjellyfish.net/garrett/apr-template/apr-template-0.0.1.tar.gz