[Zope] html templates?

Christian Scholz cs@comlounge.net
Mon, 19 Jun 2000 21:35:40 +0200


Hi!

Reading some of the recent mails of the Zope mailing lists I wonder
how people would think of the following:

Imagine writing simple html templates with some custom tags which are quite
abstract like <addresslist>. Then write some Python Product (or there might
be one Product to make this happen a little simpler) which implements these
tags.

Advantages:

- people without programming knowledge can change the page
- you will be able to override existing tags like <a href...>, e.g.
  to add a session id as additional parameter on every occurence of
  an <A>-Tag.
  Also you will be able to automatically fill in <input>-Fields e.g.
  if you edit some sort of record.
- Separate programming logic from layout. 

Of course you will have to write the tag implementations in Python but
actually I see this as advantage.. ;-)

I did this before I used Zope with my own classes, called htmlPARSER
(http://heimat.de/mrtopf/htmlparser/ ). I was quite happy with it especially
with some unpublished additions which made it very easy to write html
forms to add/edit/delete records in an sql database. Most of the
work was done automatically, you only had to write one form and specify
the fields and tables in the database in a simple list (in addition
with my mrDBC module (http://heimat.de/mrtopf/mrdbc/).

Now I wonder what people on this list think about such things.. :)

(as I sooner or later will implement this also in Python. After fiddling
around a bit with ZClasses and generating the forms and error handling by
hand..)

Some more examples:

You might define inner template in your html templates:

<template name="adritem">
<tr><td><name></td><td><address></td><td><emaillink></td></tr>
</template>

and then use it in another tag:

<addresslist tmpl='adritem'>

This would extract some address record (it's up to the implementing
function) and for each address record it will use 'adritem' to format
it. So you can use the same method with different layouts. 
It's also important that <name> is local to that template if you want.
Thus you can create templates for different lists and nevertheless use
a <name>-Tag in every one of them (if it makes sense).

More examples you can find in the htmlPARSER-Distribution.


-- christian


-- 
COM.lounge                                          http://comlounge.net/
communication & design                                 info@comlounge.net