On Sun, Jun 14, 2009 at 10:56 PM, Eddie Eyles<ho...@heddonsgate.co.uk> wrote:
>
> I'm retrieving data that may contain carriage returns, and I want to
> display this with these line breaks intact, i.e. I need to put either
> a '<br/>' or an HTML block element closure/opening in place of each
> carriage return.  I have tried the following in the view:
>
> <td>{{=row.basic.comments.replace('\n','<br/>')}}</td>
> -- this outputs '&lt;br/&gt;' instead of '<br/>', as you would expect
>
> <td>{{=row.basic.comments.replace('\n',XML('<br/>'))}}</td>
> -- this generates an error 'expected a character buffer object'
>
> <td>{{=XML(row.basic.comments.replace('\n','<br/>'))}}</td>
> -- this achieves what I want, but of course it also means the entire
> field is unescaped, leaving it vulnerable to XSS attack
>
> <td>{{=XML(row.basic.comments.replace('\n','<br/>'),sanitize=True)}}</
> td>
> -- this produces gobbledegook
>
> <td>{{=XML(row.basic.comments.replace('\n','<br>'),sanitize=True)}}</
> td>
> -- this seems to be just right (but strangely the expected '<br>' tags
> are converted to '<br/>')
>
> Am I doing the right thing with my last effort?  I am very new to both
> web2py and python.
>
> Eddie

Maybe:
{{='<br />'.join(row.basic.comments.split('\n'))}}
?
-- 
 Álvaro Justen
 Peta5 - Telecomunicações e Software Livre
 21 3021-6001 / 9898-0141
 http://www.peta5.com.br/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to