Templating engine?

has has.temp2 at virgin.net
Sun Jun 20 22:04:15 CEST 2004


Rene Pijlman <reply.in.the.newsgroup at my.address.is.invalid> wrote in message news:<2irad0dr21do731goqv510qcse24sccnh0 at 4ax.com>...
> Daniel Ellison:
> >With Cheetah (for example) there is no real chance for the template to load 
> >into an HTML editor for enhancement by a designer.
> 
> This is a good point. ZPT solves this very nicely:
> http://zpt.sourceforge.net/

ZPT still embeds programming logic within templates. Not to the same
extent as PHP does, and it manages to hide it a bit better (I nicked
ZPT's clever "hide stuff in tag attributes" idea myself), but common
programming structures - loops, conditionals and assignments - are
still firmly wedged into the HTML markup in one form or another.

PyMeld, Nevow.renderer and HTMLTemplate genuinely solve this problem
by eliminating _all_ embedded logic, reducing templates to pure HTML
markup. The only 'special' content within the template are simple name
bindings, typically stored within selected tag attributes such as
'id'. This template is converted into a basic DOM-like object model,
each named HTML element becoming an independent mutable object within
that model. Your application can then push data into this structure to
generate the finished HTML page. It's a very different approach to
macro-like web templating systems PHP, ZPT, Cheetah, etc., but very
similar to that used in desktop GUI applications.


FWIW, I've designed, written, used and killed both types of systems,
and think the DOM-style beats macro-style hands down for the majority
of use-cases, and definitely the most graphic designer-friendly
approach. Suffice to say I've no plans for killing HTMLTemplate any
time soon. ;)



More information about the Python-list mailing list