Ticket #4658: linebreaks.diff
File linebreaks.diff, 1.6 KB (added by , 17 years ago) |
---|
-
django/template/defaultfilters.py
254 254 escape = stringfilter(escape) 255 255 256 256 def 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 """ 258 263 from django.utils.html import linebreaks 259 264 return linebreaks(value) 260 265 linebreaks = stringfilter(linebreaks) 261 266 262 267 def 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 """ 264 273 return value.replace('\n', '<br />') 265 274 linebreaksbr = stringfilter(linebreaksbr) 266 275 -
docs/templates.txt
1135 1135 linebreaks 1136 1136 ~~~~~~~~~~ 1137 1137 1138 Converts newlines into ``<p>`` and ``<br />`` tags. 1138 Replaces line breaks in plain text with appropriate HTML; a single 1139 newline becomes an HTML line break (``<br />``) and a new line 1140 followed by a blank line becomes a paragraph break (``</p>``). 1139 1141 1140 1142 linebreaksbr 1141 1143 ~~~~~~~~~~~~ 1142 1144 1143 Converts newlines into ``<br />`` tags. 1145 Converts all newlines in a piece of plain text to HTML line breaks 1146 (``<br />``). 1144 1147 1145 1148 linenumbers 1146 1149 ~~~~~~~~~~~