Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #14912 -- Expanded documentation for the urlize template filter…

…. Thanks to adamv for the draft patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15086 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 645323155b3d3d952f9633446e6697247dfb1b88 1 parent 40d1a47
authored December 28, 2010

Showing 1 changed file with 28 additions and 12 deletions. Show diff stats Hide diff stats

  1. 40  docs/ref/templates/builtins.txt
40  docs/ref/templates/builtins.txt
@@ -2072,38 +2072,54 @@ If ``value`` is ``"http://www.example.org/"``, the output will be
2072 2072
 urlize
2073 2073
 ~~~~~~
2074 2074
 
2075  
-Converts URLs in plain text into clickable links.
  2075
+Converts URLs in text into clickable links.
2076 2076
 
2077  
-Note that if ``urlize`` is applied to text that already contains HTML markup,
2078  
-things won't work as expected. Apply this filter only to *plain* text.
  2077
+Works on links beginning with ``http://``, ``https://``, or ``www.`` and 
  2078
+ending with ``.org``, ``.net`` or ``.com``. Links can have trailing punctuation
  2079
+(periods, commas, close-parens) and leading punctuation (opening parens) and
  2080
+``urlize`` will still do the right thing.
  2081
+
  2082
+Links generated by ``urlize`` have a ``rel="nofollow"`` attribute added
  2083
+to them.
2079 2084
 
2080 2085
 For example::
2081 2086
 
2082 2087
     {{ value|urlize }}
2083 2088
 
2084 2089
 If ``value`` is ``"Check out www.djangoproject.com"``, the output will be
2085  
-``"Check out <a
2086  
-href="http://www.djangoproject.com">www.djangoproject.com</a>"``.
  2090
+``"Check out <a href="http://www.djangoproject.com"
  2091
+rel="nofollow">www.djangoproject.com</a>"``.
  2092
+
  2093
+The ``urlize`` filter also takes an optional parameter ``autoescape``. If
  2094
+``autoescape`` is ``True``, the link text and URLs will be escaped using
  2095
+Django's built-in :tfilter:`escape` filter. The default value for
  2096
+``autoescape`` is ``True``.
  2097
+
  2098
+.. note::
  2099
+
  2100
+    If ``urlize`` is applied to text that already contains HTML markup,
  2101
+    things won't work as expected. Apply this filter only to plain text.
2087 2102
 
2088 2103
 .. templatefilter:: urlizetrunc
2089 2104
 
2090 2105
 urlizetrunc
2091 2106
 ~~~~~~~~~~~
2092 2107
 
2093  
-Converts URLs into clickable links, truncating URLs longer than the given
2094  
-character limit.
2095  
-
2096  
-As with urlize_, this filter should only be applied to *plain* text.
  2108
+Converts URLs into clickable links just like urlize_, but truncates URLs
  2109
+longer than the given character limit.
2097 2110
 
2098  
-**Argument:** Length to truncate URLs to
  2111
+**Argument:** Number of characters that link text should be truncated to, 
  2112
+including the ellipsis that's added if truncation is necessary.
2099 2113
 
2100 2114
 For example::
2101 2115
 
2102 2116
     {{ value|urlizetrunc:15 }}
2103 2117
 
2104 2118
 If ``value`` is ``"Check out www.djangoproject.com"``, the output would be
2105  
-``'Check out <a
2106  
-href="http://www.djangoproject.com">www.djangopr...</a>'``.
  2119
+``'Check out <a href="http://www.djangoproject.com"
  2120
+rel="nofollow">www.djangopr...</a>'``.
  2121
+
  2122
+As with urlize_, this filter should only be applied to plain text.
2107 2123
 
2108 2124
 .. templatefilter:: wordcount
2109 2125
 

0 notes on commit 6453231

Please sign in to comment.
Something went wrong with that request. Please try again.