Ticket #4658: linebreaks.diff

File linebreaks.diff, 1.6 KB (added by James Bennett, 17 years ago)
  • django/template/defaultfilters.py

     
    254254escape = stringfilter(escape)
    255255
    256256def linebreaks(value):
    257     "Converts newlines into <p> and <br />s"
     257    """
     258    Replaces line breaks in plain text with appropriate HTML; a single
     259    newline becomes an HTML line break (``<br />``) and a new line
     260    followed by a blank line becomes a paragraph break (``</p>``).
     261
     262    """
    258263    from django.utils.html import linebreaks
    259264    return linebreaks(value)
    260265linebreaks = stringfilter(linebreaks)
    261266
    262267def linebreaksbr(value):
    263     "Converts newlines into <br />s"
     268    """
     269    Converts all newlines in a piece of plain text to HTML line breaks
     270    (``<br />``).
     271   
     272    """
    264273    return value.replace('\n', '<br />')
    265274linebreaksbr = stringfilter(linebreaksbr)
    266275
  • docs/templates.txt

     
    11351135linebreaks
    11361136~~~~~~~~~~
    11371137
    1138 Converts newlines into ``<p>`` and ``<br />`` tags.
     1138Replaces line breaks in plain text with appropriate HTML; a single
     1139newline becomes an HTML line break (``<br />``) and a new line
     1140followed by a blank line becomes a paragraph break (``</p>``).
    11391141
    11401142linebreaksbr
    11411143~~~~~~~~~~~~
    11421144
    1143 Converts newlines into ``<br />`` tags.
     1145Converts all newlines in a piece of plain text to HTML line breaks
     1146(``<br />``).
    11441147
    11451148linenumbers
    11461149~~~~~~~~~~~
Back to Top