[Zope-Moz] Templates anyone?

Martijn Pieters mj@digicool.com
Sun, 27 Feb 2000 09:26:52 -0500


From: Shalabh Chaturvedi [mailto:shalabh@pspl.co.in]
> There is some talk going on in the PTK list about 
> 'templates'. I have a feeling
> that if done well, something on those lines could greatly 
> benifit not only the
> PTK but also our Studio and Zope in general. Here is my pitch:
> 
> Question:
>   How many ways could one populate a html table with data from an sql
>   method ?
>   Not many, right ? It is possible to parameterize the 
> mapping. So, instead of
>   writing DTML to create a table filled with data from an 
> SQLMethods, a user
>   can just specify a set of parameters.
> 
> Picture this:
>   A designer drags 'table' icon from a toolbar and drops it in the
>   edit view of a document she is creating. She then grabs an 
> SQLMethod icon
>   (already created by a developer) and drops it onto the 
> table in the edit
>   view. Pop! up comes a box that allows the user to specify 
> the columns, order
>   etc and it's done. No DTML!
> 
> Obviously, this could be done not only for tables but other 
> elements too.
> 
> How it would work (in brief):
>   Consider a 'template' object that takes a input some 
> parameters and produces
>   *DTML*. When the template object is included in another 
> object (DTML Document
>   or Method or...) the parameters for the template are provided.
>   During rendering the DTML produced by the template is 
> evaluated and rendered.
> 
> Other issues:
>   o  The template can be evaluated to produce DTML only once 
> for each use.
>   o  Extensiblity: Anyone should be able to create their own 
> templates.

That's exactly what the component tag is so handy for:

  <dtml-let resultset="'name_of_sql_method'" show_next_prev="1"
            head="'<th>id</th><th>value</th>'">
    <dtml-component component="batched_resultstable">
      <td>&dtml-id;</td><td>&dtml-value;</td>
    </dtml-component>
  </dtml-let>

Above code would be generated by ZopeStudio.

-- 
Martijn Pieters, Software Engineer 
| Digital Creations http://www.digicool.com 
| Creators of Zope      http://www.zope.org 
| mailto:mj@digicool.com       ICQ: 4532236
| PGP:
http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 
-------------------------------------------