Thanks Anthony, it works perfectly.

在 2013年3月27日星期三UTC+8下午9时10分28秒,Anthony写道:
>
> When a text field is submitted, line breaks are stored as standard line 
> break characters (i.e., "\n"). When you then insert the stored text into 
> HTML, the line breaks will be included in the HTML, but browsers ignore 
> line breaks when rendering (i.e., they are treated as single spaces). If 
> you want to convert text line breaks to HTML line breaks (i.e., <br /> 
> elements), you have to do so explicitly -- for example:
>
> {{=XML(lead.f_description.replace('\n', '<br />'), sanitize=True)}}
>
> Wrapping the string in XML() is necessary to prevent the web2py template 
> engine from escaping the <br /> elements, and sanitize=True keeps XML() 
> safe from insecure code that might be injected into the submitted text.
>
> Anthony
>
> On Wednesday, March 27, 2013 3:33:50 AM UTC-4, Spring wrote:
>>
>> Hello there,
>>
>> I have defined a 'text' field in the table. The content consists of 
>> multiple paragraphs, when displayed in the view the content squeezes into a 
>> single line. It seems all 'enter' in original text was replaced by a 
>> "space". How can I display the text as paragraphs as it is input? Thanks 
>> for any replay.
>>
>> related piece of code:
>>
>> #Model
>> db.define_table('t_leads',
>>     Field('f_owner', type='string',
>>           label=T('Owner')),
>>     Field('f_location', type='string',
>>           label=T('Location')),
>>     Field('f_status', type='string',
>>           label=T('Status')),
>>     Field('f_description', type='text',
>>           label=T('Description')),
>>     auth.signature,
>>
>>     format='%(f_lead_designation)s',
>>     migrate=settings.migrate)
>>
>>
>> #View
>> <td bgcolor="#FFFFFF">{{=lead.f_description}}</td>
>>
>>

-- 

--- 
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/groups/opt_out.


Reply via email to