Discussion:
What is Django/python equivalent of this - Display textarea content with line breaks in html page?
zweb
2009-01-11 02:13:00 UTC
Permalink
Javascript:
document.getElemnetById(’textareacontent’).value.replace(/\n/
g,’<br>’);
PHP:
preg_replace(”/\n/”,”<br>”,$_REQUEST['t1']);
Ruby:
(teaxtareacontent).gsub(/\n/,”<br>”)

( reference - http://rkutti.wordpress.com/2008/01/31/display-textarea-content-with-line-breaks-in-html-page/)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Brian Neal
2009-01-11 03:48:29 UTC
Permalink
Post by zweb
document.getElemnetById(’textareacontent’).value.replace(/\n/
g,’<br>’);
preg_replace(”/\n/”,”<br>”,$_REQUEST['t1']);
(teaxtareacontent).gsub(/\n/,”<br>”)
( reference -http://rkutti.wordpress.com/2008/01/31/display-textarea-content-with-...)
I'm not exactly sure what you mean, as you don't want to put a <br />
inside a text area without escaping it.

If you are talking about displaying text that you got from a text
area, then the PHP idiom is nl2br().

In Django templates, see the linebreaks and linebreaksbr filters:

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#linebreaks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Loading...