DTML Theme Support

DTML (DocumentTemplate -- sorry, the page behind the link is hard to read because of those user comments...) is the template 'language' of the Zope project. It gives the ability to in-line formatting instructions into html, without getting to much code specific. So the Template designer normally does not have to know python to make his own theme.

There are no plans currently implementing or incorporating a template language that is not python.

I think this should read: there are no official plans, cause obviously I have those plans...

The point of view of some developers (IIRC JH, TW, FF, maybe some more) was / is that it is pointless to have some sort of additional templating language (no matter whether invented here or imported from some other project) because it will either be too simple to do all we need or just be another non-trivial language to learn - although it could be done in python also. So the python solution is more efficient as in that case you have to know python only - and you can use that knowledge to do all sorts of other things, too. Also, it would be either additional stuff to maintain and document, or an additional dependency.

Sorry, but my experience tells me that a template based system is better, cause it tries to separate code from display. And when it comes to design, this is always an advantage. On the other hand it seems that you did not read something about DTML, or you would see that it is nothing new or complex to learn.

Example

For a simple example we will take a look at the PageTrail: assume the trail would be saved as a list of objects (very simple example!):

   1 class TrailItem:
   2     def __init__(self, name, url):
   3         self.name=name
   4         self.url= url
   5 
   6 mytrail=[TrailItem('Page1','/Page/1'), TrailItem('Page2','/Page/2'), TrailItem('Page3','/Page/3')]

Note: you could also use just dicts, but making objects of the stuff opens ways to manipulate the data while setting or getting it.

Now we need a DTML template to display the trail:

<ul id="pagetrail">
  <dtml-in trail>
    <li><a href="<dtml-var url>"><dtml-var name></a></li>
  </dtml-in>
</ul>

Now just call the template with the data (assume that the trail definition above belongs to the same piece of code):

   1 dtml=HTMLFile('path/to/our/template')
   2 return dtml(trail=trail)

Note: We use kwargs in this example. Normally the first arg to a DTML is the object that calls (and hold all the data), the second arg should be a dict like object (normally holding env, form, and custom vars). The kwargs always override the other two. So the normal call should be dtml(page,request), while page is the object that holds the page and all attached stuff, and the request would be our normal request (with the user object for example which would hold the pagetrail...).

Discussion

This looks very nice - but it could still be a problem - who create the texts inside the TrailItems. For example, the text could be "PageName - description". If this is hardcoded into Page.py, as is the situation today with some texts, then the theme designer will have hard time if he wants to implement a trail without the description, or the opposite - adding a description.

It would be nice if we can put all the texts in the on object, and let other collect the data for it from all sorts of sources. So the theme could be implemented with this dtml system, and the layout - what theme parts will be used and what content will be sent into them will be the role of another object.

To create a new theme - you could play with css and dtml. To create a new MoinMoin-Application - a different view system using the same backend, you could create a new view object.

-- NirSoffer 2004-01-31 13:35:33

The way to go would be to try to abstract some of the storage models of Moin to get a better division between data and display. This would help programmed themes also. Than a DTML Theme could be created which is sort of a meta theme, cause it would just provide the data to a set of dtml file which do the display.

-- OliverGraf 2004-02-01 08:07:00

MoinMoin: OliverGraf/DtmlThemeSupport (last edited 2007-10-29 19:19:59 by localhost)