[Zope] convert <dml-var TEXT> to bullet list

Marcus Collins mcollins@sunesi.com
Thu, 13 Apr 2000 09:02:03 +0200


> -----Original Message-----
> From: Jorge Magalhaes [mailto:root@predict.telepac.pt]
> Sent: 13 April 2000 01:46
> To: zope@zope.org
> Subject: [Zope] convert <dml-var TEXT> to bullet list
 
> In <dtml-var description> (description type is text) how i can convert
> newlines characters, carriage-return characters, and new-line-
> carriage-return character combinations to a HTML tag for making a
> bullet list item.

Hi,

The following snippet will take an arbitrary text variable, split in on
newline boundaries, and generate a bulleted list.

<dtml-in "_.string.split(text, '\n')">
  <dtml-if sequence-start>
    <ul>
  </dtml-if>
  <li><dtml-var sequence-item>
  <dtml-if sequence-end>
    </ul>
  </dtml-if>
</dtml-in>

If you need to handle \n\r pairs as well, you could use string.replace to
handle the conversion. However, the above should work even with \n\r, as it
will just leave a leading \r in the text.

hth,

-- Marcus