[ANN] HTMLTemplate 1.0.0

has has.temp2 at virgin.net
Fri Jun 4 10:20:06 EDT 2004


Duncan Booth <me at privacy.net> wrote in message news:<Xns94FCE5978C3BFduncanrcpcouk at 127.0.0.1>...

> I got the impression that your HTMLTemplate was quite similar in concept to 
> TAL but less powerful (probably deliberately). Certainly it looks as though 
> most of your constructs map straight onto a very similar TAL expression.

Appearances, as they say, can be deceiving.<g> While some of the
original inspiration for HTMLTemplate did come from studying Zope Page
Templates (particularly the trick of hiding stuff in tag attributes so
templates can double as decent page mockups) the two systems are
_very_ different in concept and operation:

- TAL is based on a custom embedded language that provides basic
insertion and flow-control capabilities, allowing TAL templates to
pull data from a supplied data source to do their funky page rendering
thing.

- HTMLTemplate (like PyMeld and Nevow.Renderer) presents a template as
a very simple, custom DOM that is built and manipulated completely in
Python, the data being pushed into the compiled Template's object
model via a simple programmatic API.


Admittedly, HTMLTemplate's "compiler directives" do look a lot like
TAL expressions, at least to a casual observer, but their similarity
is superficial:

- TAL directives are responsible for controlling both template
construction AND rendering. The only thing your Python scripts do is
assemble your source data into TAL-digestible form, then serve it up
to the TAL template which will produce the rendered page.

- an HTMLTemplate directive is just a simple type declaration and name
binding - data used only to construct the template object mode, _not_
to render it. ALL presentation logic is implemented as part of your
Python scripts, which then interact directly with the Template object
model to produce the rendered page.


As to HTMLTemplate appearing "less powerful" than TAL, I suspect this
is more a problem of perception than actual implementation. (If
anything, would say the opposite was actually true, and HTMLTemplate
is probably a good bit more powerful than most other templating
systems available.) It's is certainly simple; however, that's not the
same thing as "low powered", and in this case Less is _definitely_
More. HTMLTemplate simply doesn't need to provide scads of built-in
functionality because it's designed from scratch to integrate
seamlessly with Python - allowing you to lever all the power of the
Python language and its myriad libraries at a level where most
templating engines can't/won't/don't even let you in. Something that
seems obvious to me now; but for a very long time (read: several
years:p) it wasn't.[1] Ah well, ya live and learn.<g>


Hope that clarifies (and if it tempts you to try it, maybe you can let
us know how that goes)

has

[1] It's no coincidence I started HTMLTemplate about the same times I
discovered Unix philosophy; i.e. "Keep it small, simple and highly
focussed, and design it to play really, really well with others." Best
advice ever. Took me three bloated, incomprehensible and appallingly
ill-conceived monsters to learn that lesson myself, but fourth time's
the charm, eh?;)



More information about the Python-list mailing list