[Web-SIG] htmlgen
Greg Stein
gstein at lyra.org
Fri Oct 31 01:33:29 EST 2003
On Thu, Oct 30, 2003 at 10:44:52AM -0600, Ian Bicking wrote:
> On Thursday, October 30, 2003, at 10:33 AM, Gregory (Grisha) Trubetskoy
> wrote:
> > HTMLgen has a DocumentTemplate thing which is a bare bones templating
> > system allowing for substitution in a text file. I think something
> > primitive of this sort and perhaps implemented based on this:
> >
> > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81330
> >
> > (which can probably be even further optimized)
> >
> > would be nice to have in stdlib.
>
> A templating system in its most naive form is just a kind of string
> substitution. If that's the kind of thing we're looking for, then
> perhaps -- but it has to be usefully better than %. (Though % would be
Right. Simple interpolation is rarely enough. The features that I found to
be useful in a templating system:
* interpolation
* conditionals
* iteration
* structured objects (i.e. something like: foo.bar)
* including sub-templates
I've also found that *restricting* the functionality to just this limited
set helps to provide clarity and avoid complex abuses of templates. I look
at the task simply as "rendering data" and prefer a simple syntax and
functionality to match that.
Cheers,
-g
p.s. yah yah, this is an implicit pimping of my ezt module :-)
http://svn.webdav.org/repos/projects/ezt/trunk/ezt.py
--
Greg Stein, http://www.lyra.org/
More information about the Web-SIG
mailing list