C..4 Cheetah vs. Zope's DTML

For a basic introduction to DTML, visit http://www.zope.org/Members/michel/ZB/DTML.dtml.

Here are some examples of syntax differences between DTML and Cheetah:

<ul>
<dtml-in frogQuery>
 <li><dtml-var animal_name></li>
</dtml-in>
</ul>

<ul>
#for $animal_name in $frogQuery
 <li>$animal_name</li>
#end for
</ul>

<dtml-if expr="monkeys > monkey_limit">
  <p>There are too many monkeys!</p>
<dtml-elif expr="monkeys < minimum_monkeys">
  <p>There aren't enough monkeys!</p>
<dtml-else>
  <p>There are just enough monkeys.</p>
</dtml-if>

#if $monkeys > $monkey_limit
  <p>There are too many monkeys!</p>
#else if $monkeys < $minimum_monkeys
  <p>There aren't enough monkeys!</p>
#else
  <p>There are just enough monkeys.</p>
#end if

<table>
<dtml-in expr="objectValues('File')">
  <dtml-if sequence-even>
    <tr bgcolor="grey">
  <dtml-else>
    <tr>
  </dtml-if>    
  <td>
  <a href="&dtml-absolute_url;"><dtml-var title_or_id></a>
  </td></tr>
</dtml-in>
</table>

<table>
#set $evenRow = 0
#for $file in $files('File')
  #if $evenRow
    <tr bgcolor="grey">
    #set $evenRow = 0
  #else
    <tr>
    #set $evenRow = 1
  #end if
  <td>
  <a href="$file.absolute_url">$file.title_or_id</a>
  </td></tr>
#end for
</table>

The last example changed the name of $objectValues to $files because that's what a Cheetah developer would write. The developer would be responsible for ensuring $files returned a list (or tuple) of objects (or dictionaries) containing the attributes (or methods or dictionary keys) `absolute_url' and `title_or_id'. All these names (`objectValues', `absolute_url' and `title_or_id') are standard parts of Zope, but in Cheetah the developer is in charge of writing them and giving them a reasonable behaviour.

Some of DTML's features are being ported to Cheetah, such as Cheetah.Tools.MondoReport, which is based on the <dtml-in> tag. We are also planning an output filter as flexible as the <dtml-var> formatting options. However, neither of these are complete yet.