From cadc6e8c9fab8c56d50e8bb3e92519e0caca03b7 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 14 Sep 2007 21:46:38 +0000 Subject: [PATCH] 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 --- django/template/defaultfilters.py | 11 +++++++++-- docs/templates.txt | 7 +++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py index 22babfd6c0..1fd6d02c70 100644 --- a/django/template/defaultfilters.py +++ b/django/template/defaultfilters.py @@ -254,13 +254,20 @@ def escape(value): escape = stringfilter(escape) def linebreaks(value): - "Converts newlines into

and
s" + """ + Replaces line breaks in plain text with appropriate HTML; a single + newline becomes an HTML line break (``
``) and a new line + followed by a blank line becomes a paragraph break (``

``). + """ from django.utils.html import linebreaks return linebreaks(value) linebreaks = stringfilter(linebreaks) def linebreaksbr(value): - "Converts newlines into
s" + """ + Converts all newlines in a piece of plain text to HTML line breaks + (``
``). + """ return value.replace('\n', '
') linebreaksbr = stringfilter(linebreaksbr) diff --git a/docs/templates.txt b/docs/templates.txt index 0c8cc79311..dbed0ba5c9 100644 --- a/docs/templates.txt +++ b/docs/templates.txt @@ -1135,12 +1135,15 @@ Returns a boolean of whether the value's length is the argument. linebreaks ~~~~~~~~~~ -Converts newlines into ``

`` and ``
`` tags. +Replaces line breaks in plain text with appropriate HTML; a single +newline becomes an HTML line break (``
``) and a new line +followed by a blank line becomes a paragraph break (``

``). linebreaksbr ~~~~~~~~~~~~ -Converts newlines into ``
`` tags. +Converts all newlines in a piece of plain text to HTML line breaks +(``
``). linenumbers ~~~~~~~~~~~