[web2py] Re: Line Breaks in DAL Entries

2014-05-01 Thread Anthony
Are you saying you want to retain the line breaks when it is rendered in 
HTML (e.g., in a grid or read-only form)? If so, you can do something like:

Field('myfield', 'text', represent=lambda v, r: XML(v.replace('\n', 'br'
)))

or

Field('myfield', 'text', represent=lambda v, r: PRE(v))

Anthony

On Thursday, May 1, 2014 3:24:16 PM UTC-4, Mark Billion wrote:

 I have a database entry that looks like this when I enter the DB admin:

 Mark's Restaurant 

 MEAL PLAN 

 NOTICE

 When it prints, I get:

 Mark's Restaurant MEAL PLAN NOTICE

 My problem is that I would like to split the text by line but I cant 
 figure out what the raw symbol is for the break (i.e., \r\n), as when I add 
 these, they are ignored.  Can you point me in the right direction.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Line Breaks in DAL Entries

2014-05-01 Thread Mark Billion
Perfect.  Thank you so much.

On Thursday, May 1, 2014 4:27:51 PM UTC-4, Anthony wrote:

 Are you saying you want to retain the line breaks when it is rendered in 
 HTML (e.g., in a grid or read-only form)? If so, you can do something like:

 Field('myfield', 'text', represent=lambda v, r: XML(v.replace('\n', 'br'
 )))

 or

 Field('myfield', 'text', represent=lambda v, r: PRE(v))

 Anthony

 On Thursday, May 1, 2014 3:24:16 PM UTC-4, Mark Billion wrote:

 I have a database entry that looks like this when I enter the DB admin:

 Mark's Restaurant 

 MEAL PLAN 

 NOTICE

 When it prints, I get:

 Mark's Restaurant MEAL PLAN NOTICE

 My problem is that I would like to split the text by line but I cant 
 figure out what the raw symbol is for the break (i.e., \r\n), as when I add 
 these, they are ignored.  Can you point me in the right direction.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.