Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #4658 -- Improved documentation of linebreaks and linebreaksbr.…

… Thanks, ubernostrum and Gary Wilson

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6223 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit cadc6e8c9fab8c56d50e8bb3e92519e0caca03b7 1 parent b522469
@adrianholovaty adrianholovaty authored
Showing with 14 additions and 4 deletions.
  1. +9 −2 django/template/defaultfilters.py
  2. +5 −2 docs/templates.txt
View
11 django/template/defaultfilters.py
@@ -254,13 +254,20 @@ def escape(value):
escape = stringfilter(escape)
def linebreaks(value):
- "Converts newlines into <p> and <br />s"
+ """
+ Replaces line breaks in plain text with appropriate HTML; a single
+ newline becomes an HTML line break (``<br />``) and a new line
+ followed by a blank line becomes a paragraph break (``</p>``).
+ """
from django.utils.html import linebreaks
return linebreaks(value)
linebreaks = stringfilter(linebreaks)
def linebreaksbr(value):
- "Converts newlines into <br />s"
+ """
+ Converts all newlines in a piece of plain text to HTML line breaks
+ (``<br />``).
+ """
return value.replace('\n', '<br />')
linebreaksbr = stringfilter(linebreaksbr)
View
7 docs/templates.txt
@@ -1135,12 +1135,15 @@ Returns a boolean of whether the value's length is the argument.
linebreaks
~~~~~~~~~~
-Converts newlines into ``<p>`` and ``<br />`` tags.
+Replaces line breaks in plain text with appropriate HTML; a single
+newline becomes an HTML line break (``<br />``) and a new line
+followed by a blank line becomes a paragraph break (``</p>``).
linebreaksbr
~~~~~~~~~~~~
-Converts newlines into ``<br />`` tags.
+Converts all newlines in a piece of plain text to HTML line breaks
+(``<br />``).
linenumbers
~~~~~~~~~~~
Please sign in to comment.
Something went wrong with that request. Please try again.