[Zope-Moz] Templates anyone?
Martijn Pieters
mj@digicool.com
Sun, 27 Feb 2000 10:12:36 -0500
From: Shalabh Chaturvedi [mailto:shalabh@pspl.co.in]
> > It just is a callable object, that gets fed a attribute named
> > component-contents with the dtml code in within the block in it.
>
> I feel this might not be enough. There should not be just _one_
> component_contents but it should be possible to pass any
> number of parameters
> to the template. Like so:
>
> <dtml-component template="table_filled_with_results"
> query="mySQLMeth"
> columns2use="Name, Age"
> tableAttributes=" width=100% "
> >
>
>
> And the template 'table_filled_with_results' is defined as:
>
> <table (tableAttributes) >
>
> <tr>
> (for each columnName in columns2use)
> <th> [columnName]
> (end for)
>
> <dtml-in [query]>
> (for each columnName in columns2use)
> <tr> <td> <dtml-var [columnName]>
> (end for)
> </dtml-in>
>
> </table>
>
> How this _could_ work is as follows:
>
> The template 'table_filled_with_results' gets evaluated
> _once_ when the the
> document containing <dtml-component> is saved. This would
> produce the following
> DTML:
>
> <table width=100%>
> <tr>
> <th> Name
> <th> Age
> <dtml-in mySQLMeth>
> <tr> <td> <dtml-var Name>
> <td> <dtml-var Age>
> </dtml-in>
> </table>
>
> This is exactly what we want to use. During publishing, this
> DTML would be
> evaluated as if it was included with a simple <dtml-var> instead of
> <dtml-component>.
> Also note that the above template cannot be defined in plain
> dtml. It would
> need
> special syntax since it itself is 'producing' DTML which
> later gets evaluated
> at
> publish time.
But you can no longer make any changes to the component source then,
unless you hunt down all the DTML methods it is used in and re-parse
those as well! Not very elegant I'd say.
No, the component should be any callable Zope object. That way you keep
it OO and reusable.
--
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
-------------------------------------------