[ZPT] newline_to_br in zpt???

Evan Simpson evan@digicool.com
Mon, 23 Apr 2001 18:09:13 -0400


From: "daniel dias" <diask8@yahoo.com.br>
> How to I replace new lines to br in my templates??

This is a weak area of the specification.  One of the nicer things about
DTML is the easy way that you can add formatting filters to inserted text
(*_quote, newline_to_br, date formats, etc.). Right now, the closest that
ZPT can come is to use the 'modules' variable in the soon-to-be-released
1.2:

tal:define="std modules/Products.PythonScripts.standard"
tal:replace="python:std.newline_to_br(txt)"

This isn't good enough, I think.  We can easily come up with a more
reasonably named module to contain standard formats, and I expect that users
will often want to apply both standard and user-defined filters.  I'll toss
out one possibility; How about an expression type?  Example:

tal:replace="filter:std/newline_to_br;filter:here/myFilter;txt"

Hmm.  Not much better, really, but at least it doesn't require Python.

Cheers,

Evan @ digicool