[Zope] spaces to  

Ben Avery ben@thesite.org
Fri, 14 Feb 2003 13:51:23 +0000


<pre> is a bit nasty, if you have a paragraph of text as a single line, 
with no line breaks, it will put this one one huge wide line requiring 
scrolling.

This would be quite handy for me too, so I've hacked the source to add a 
new format - very easy to do, and useful if you would use it often enough.
retro-fit this diff to
lib/python/DocumentTemplate/DT_Var.py

diff DT_Var.py DT_Var.py_bkp
416,420d415
< def space_to_nbsp(v, name='(Unknown name)', md={}):
<     """Changes all space characters to &nbsp; nonbreaking
<     """
<     if v.find(" ") >= 0: return v.replace(" ", "&nbsp;")
<     return v
436d430
<     'space_to_nbsp': space_to_nbsp,


then you can use <dtml-var myvar fmt=space_to_nbsp>


Jaroslav Lukesh wrote:
> | Odesílatel: Ulla Theiss <u.theiss@eurodata.de>
> | does anybody know, if there is a possibility in dtml, to let a dtml-var
> | replace spaces to non breaking 
> | spaces (&nbsp;)?
> | <dtml-var ... newline_to_br>
> 
> Try this way:
> 
> <pre><font face="arial"><dtml-var ... ></font></pre>
> 
> JL.
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
>